mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 05:27:45 +00:00
LibProtocol: Pass response headers in a case insensitive HashMap
HTTP headers are case-insensitive, so just add CaseInsensitiveTraits to the HashMap and we're good to go! :^)
This commit is contained in:
parent
aef5d28828
commit
20f50f9133
6 changed files with 16 additions and 10 deletions
|
@ -53,7 +53,13 @@ void Download::did_finish(Badge<Client>, bool success, u32 total_size, i32 shbuf
|
|||
payload = ByteBuffer::wrap(shared_buffer->data(), total_size);
|
||||
}
|
||||
|
||||
on_finish(success, payload, move(shared_buffer), response_headers.entries());
|
||||
// FIXME: It's a bit silly that we copy the response headers here just so we can move them into a HashMap with different traits.
|
||||
HashMap<String, String, CaseInsensitiveStringTraits> caseless_response_headers;
|
||||
response_headers.for_each_entry([&](auto& name, auto& value) {
|
||||
caseless_response_headers.set(name, value);
|
||||
});
|
||||
|
||||
on_finish(success, payload, move(shared_buffer), caseless_response_headers);
|
||||
}
|
||||
|
||||
void Download::did_progress(Badge<Client>, Optional<u32> total_size, u32 downloaded_size)
|
||||
|
@ -61,5 +67,4 @@ void Download::did_progress(Badge<Client>, Optional<u32> total_size, u32 downloa
|
|||
if (on_progress)
|
||||
on_progress(total_size, downloaded_size);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include <AK/ByteBuffer.h>
|
||||
#include <AK/Function.h>
|
||||
#include <AK/RefCounted.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/WeakPtr.h>
|
||||
#include <LibIPC/Forward.h>
|
||||
|
||||
|
@ -47,7 +48,7 @@ public:
|
|||
int id() const { return m_download_id; }
|
||||
bool stop();
|
||||
|
||||
Function<void(bool success, const ByteBuffer& payload, RefPtr<SharedBuffer> payload_storage, const HashMap<String, String>& response_headers)> on_finish;
|
||||
Function<void(bool success, const ByteBuffer& payload, RefPtr<SharedBuffer> payload_storage, const HashMap<String, String, CaseInsensitiveStringTraits>& response_headers)> on_finish;
|
||||
Function<void(Optional<u32> total_size, u32 downloaded_size)> on_progress;
|
||||
|
||||
void did_finish(Badge<Client>, bool success, u32 total_size, i32 shbuf_id, const IPC::Dictionary& response_headers);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue