1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 21:17:45 +00:00

LibWeb: Change Resource's m_encoding to Optional<String>

This modifies the Resource class to use Optional<String> for the
encoding. If the encoding is unknown, the Optional will not have a
value (instead of using the null state of the String class). It also
implements a has_encoding() instance method and modifies the callers
of Resource::encoding() to use the new API.
This commit is contained in:
Max Wipfli 2021-05-12 10:21:00 +02:00 committed by Andreas Kling
parent ce6d6706a6
commit a7681dbeea
3 changed files with 11 additions and 7 deletions

View file

@ -52,7 +52,8 @@ public:
void register_client(Badge<ResourceClient>, ResourceClient&);
void unregister_client(Badge<ResourceClient>, ResourceClient&);
const String& encoding() const { return m_encoding; }
bool has_encoding() const { return m_encoding.has_value(); }
const Optional<String>& encoding() const { return m_encoding; }
const String& mime_type() const { return m_mime_type; }
void for_each_client(Function<void(ResourceClient&)>);
@ -70,7 +71,8 @@ private:
bool m_loaded { false };
bool m_failed { false };
String m_error;
String m_encoding;
Optional<String> m_encoding;
String m_mime_type;
HashMap<String, String, CaseInsensitiveStringTraits> m_response_headers;
Optional<u32> m_status_code;