mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-21 23:20:20 +00:00
LibHTTP+ProtocolServer: Use CaseInsensitiveStringTraits for headers
These are supposed to be interpreted caselessly so let's just use the case insensitive traits throughout. This means we'll understand things like "Content-Length" even when they send "content-length" etc.
This commit is contained in:
parent
413ab652c8
commit
8b8a5fc6c6
Notes:
sideshowbarker
2024-07-19 06:42:08 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/8b8a5fc6c6f
5 changed files with 10 additions and 10 deletions
|
@ -28,7 +28,7 @@
|
|||
|
||||
namespace HTTP {
|
||||
|
||||
HttpResponse::HttpResponse(int code, HashMap<String, String>&& headers, ByteBuffer&& payload)
|
||||
HttpResponse::HttpResponse(int code, HashMap<String, String, CaseInsensitiveStringTraits>&& headers, ByteBuffer&& payload)
|
||||
: Core::NetworkResponse(move(payload))
|
||||
, m_code(code)
|
||||
, m_headers(move(headers))
|
||||
|
|
|
@ -35,19 +35,19 @@ namespace HTTP {
|
|||
class HttpResponse : public Core::NetworkResponse {
|
||||
public:
|
||||
virtual ~HttpResponse() override;
|
||||
static NonnullRefPtr<HttpResponse> create(int code, HashMap<String, String>&& headers, ByteBuffer&& payload)
|
||||
static NonnullRefPtr<HttpResponse> create(int code, HashMap<String, String, CaseInsensitiveStringTraits>&& headers, ByteBuffer&& payload)
|
||||
{
|
||||
return adopt(*new HttpResponse(code, move(headers), move(payload)));
|
||||
}
|
||||
|
||||
int code() const { return m_code; }
|
||||
const HashMap<String, String>& headers() const { return m_headers; }
|
||||
const HashMap<String, String, CaseInsensitiveStringTraits>& headers() const { return m_headers; }
|
||||
|
||||
private:
|
||||
HttpResponse(int code, HashMap<String, String>&&, ByteBuffer&&);
|
||||
HttpResponse(int code, HashMap<String, String, CaseInsensitiveStringTraits>&&, ByteBuffer&&);
|
||||
|
||||
int m_code { 0 };
|
||||
HashMap<String, String> m_headers;
|
||||
HashMap<String, String, CaseInsensitiveStringTraits> m_headers;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -73,7 +73,7 @@ protected:
|
|||
HttpRequest m_request;
|
||||
State m_state { State::InStatus };
|
||||
int m_code { -1 };
|
||||
HashMap<String, String> m_headers;
|
||||
HashMap<String, String, CaseInsensitiveStringTraits> m_headers;
|
||||
Vector<ByteBuffer> m_received_buffers;
|
||||
size_t m_received_size { 0 };
|
||||
bool m_sent_data { 0 };
|
||||
|
|
|
@ -64,7 +64,7 @@ void Download::set_payload(const ByteBuffer& payload)
|
|||
m_total_size = payload.size();
|
||||
}
|
||||
|
||||
void Download::set_response_headers(const HashMap<String, String>& response_headers)
|
||||
void Download::set_response_headers(const HashMap<String, String, CaseInsensitiveStringTraits>& response_headers)
|
||||
{
|
||||
m_response_headers = response_headers;
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ public:
|
|||
Optional<u32> total_size() const { return m_total_size; }
|
||||
size_t downloaded_size() const { return m_downloaded_size; }
|
||||
const ByteBuffer& payload() const { return m_payload; }
|
||||
const HashMap<String, String>& response_headers() const { return m_response_headers; }
|
||||
const HashMap<String, String, CaseInsensitiveStringTraits>& response_headers() const { return m_response_headers; }
|
||||
|
||||
void stop();
|
||||
|
||||
|
@ -57,7 +57,7 @@ protected:
|
|||
void did_finish(bool success);
|
||||
void did_progress(Optional<u32> total_size, u32 downloaded_size);
|
||||
void set_payload(const ByteBuffer&);
|
||||
void set_response_headers(const HashMap<String, String>&);
|
||||
void set_response_headers(const HashMap<String, String, CaseInsensitiveStringTraits>&);
|
||||
|
||||
private:
|
||||
i32 m_id;
|
||||
|
@ -65,6 +65,6 @@ private:
|
|||
Optional<u32> m_total_size {};
|
||||
size_t m_downloaded_size { 0 };
|
||||
ByteBuffer m_payload;
|
||||
HashMap<String, String> m_response_headers;
|
||||
HashMap<String, String, CaseInsensitiveStringTraits> m_response_headers;
|
||||
WeakPtr<PSClientConnection> m_client;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue