LibWeb: Make LoadRequest headers case insensitive

This commit is contained in:
leeight 2022-10-14 04:57:12 +08:00 committed by Linus Groh
parent 9b61579aa6
commit 1167fdb17a
Notes: sideshowbarker 2024-07-17 07:35:03 +09:00
2 changed files with 3 additions and 4 deletions

View file

@ -229,7 +229,6 @@ bool FrameLoader::load(LoadRequest& request, Type type)
// -> "frame"
// -> "iframe"
// `text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8`
// FIXME: This should be case-insensitive.
if (!request.headers().contains("Accept"))
request.set_header("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");

View file

@ -53,7 +53,7 @@ public:
{
if (m_headers.size() != other.m_headers.size())
return false;
for (auto& it : m_headers) {
for (auto const& it : m_headers) {
auto jt = other.m_headers.find(it.key);
if (jt == other.m_headers.end())
return false;
@ -66,12 +66,12 @@ public:
void set_header(String const& name, String const& value) { m_headers.set(name, value); }
String header(String const& name) const { return m_headers.get(name).value_or({}); }
HashMap<String, String> const& headers() const { return m_headers; }
HashMap<String, String, CaseInsensitiveStringTraits> const& headers() const { return m_headers; }
private:
AK::URL m_url;
String m_method { "GET" };
HashMap<String, String> m_headers;
HashMap<String, String, CaseInsensitiveStringTraits> m_headers;
ByteBuffer m_body;
Core::ElapsedTimer m_load_timer;
Optional<Page&> m_page;