diff --git a/Applications/Browser/DownloadWidget.cpp b/Applications/Browser/DownloadWidget.cpp index 71b618656d..a187c68d52 100644 --- a/Applications/Browser/DownloadWidget.cpp +++ b/Applications/Browser/DownloadWidget.cpp @@ -59,7 +59,7 @@ DownloadWidget::DownloadWidget(const URL& url) m_download->on_progress = [this](Optional total_size, u32 downloaded_size) { did_progress(total_size.value(), downloaded_size); }; - m_download->on_finish = [this](bool success, const ByteBuffer& payload, RefPtr payload_storage, const HashMap& response_headers) { + m_download->on_finish = [this](bool success, auto& payload, auto payload_storage, auto& response_headers) { did_finish(success, payload, payload_storage, response_headers); }; @@ -156,7 +156,7 @@ void DownloadWidget::did_progress(Optional total_size, u32 downloaded_size) } } -void DownloadWidget::did_finish(bool success, const ByteBuffer& payload, RefPtr payload_storage, const HashMap& response_headers) +void DownloadWidget::did_finish(bool success, const ByteBuffer& payload, RefPtr payload_storage, const HashMap& response_headers) { (void)payload; (void)payload_storage; diff --git a/Applications/Browser/DownloadWidget.h b/Applications/Browser/DownloadWidget.h index 9c632bbfc6..95fec634d5 100644 --- a/Applications/Browser/DownloadWidget.h +++ b/Applications/Browser/DownloadWidget.h @@ -44,7 +44,7 @@ private: explicit DownloadWidget(const URL&); void did_progress(Optional total_size, u32 downloaded_size); - void did_finish(bool success, const ByteBuffer& payload, RefPtr payload_storage, const HashMap& response_headers); + void did_finish(bool success, const ByteBuffer& payload, RefPtr payload_storage, const HashMap& response_headers); URL m_url; String m_destination_path; diff --git a/Libraries/LibProtocol/Download.cpp b/Libraries/LibProtocol/Download.cpp index 103964a93f..616321df92 100644 --- a/Libraries/LibProtocol/Download.cpp +++ b/Libraries/LibProtocol/Download.cpp @@ -53,7 +53,13 @@ void Download::did_finish(Badge, 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 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, Optional total_size, u32 downloaded_size) @@ -61,5 +67,4 @@ void Download::did_progress(Badge, Optional total_size, u32 downloa if (on_progress) on_progress(total_size, downloaded_size); } - } diff --git a/Libraries/LibProtocol/Download.h b/Libraries/LibProtocol/Download.h index 883406e8b3..4934e54fb9 100644 --- a/Libraries/LibProtocol/Download.h +++ b/Libraries/LibProtocol/Download.h @@ -30,6 +30,7 @@ #include #include #include +#include #include #include @@ -47,7 +48,7 @@ public: int id() const { return m_download_id; } bool stop(); - Function payload_storage, const HashMap& response_headers)> on_finish; + Function payload_storage, const HashMap& response_headers)> on_finish; Function total_size, u32 downloaded_size)> on_progress; void did_finish(Badge, bool success, u32 total_size, i32 shbuf_id, const IPC::Dictionary& response_headers); diff --git a/Libraries/LibWeb/ResourceLoader.cpp b/Libraries/LibWeb/ResourceLoader.cpp index f8d6be8b51..bbaa45fa62 100644 --- a/Libraries/LibWeb/ResourceLoader.cpp +++ b/Libraries/LibWeb/ResourceLoader.cpp @@ -47,7 +47,7 @@ ResourceLoader::ResourceLoader() { } -void ResourceLoader::load_sync(const URL& url, Function& response_headers)> success_callback, Function error_callback) +void ResourceLoader::load_sync(const URL& url, Function& response_headers)> success_callback, Function error_callback) { Core::EventLoop loop; @@ -66,7 +66,7 @@ void ResourceLoader::load_sync(const URL& url, Function& response_headers)> success_callback, Function error_callback) +void ResourceLoader::load(const URL& url, Function& response_headers)> success_callback, Function error_callback) { if (is_port_blocked(url.port())) { dbg() << "ResourceLoader::load: Error: blocked port " << url.port() << " for URL: " << url; diff --git a/Libraries/LibWeb/ResourceLoader.h b/Libraries/LibWeb/ResourceLoader.h index 74f9e2426e..7bca500a60 100644 --- a/Libraries/LibWeb/ResourceLoader.h +++ b/Libraries/LibWeb/ResourceLoader.h @@ -41,8 +41,8 @@ class ResourceLoader : public Core::Object { public: static ResourceLoader& the(); - void load(const URL&, Function& response_headers)> success_callback, Function error_callback = nullptr); - void load_sync(const URL&, Function& response_headers)> success_callback, Function error_callback = nullptr); + void load(const URL&, Function& response_headers)> success_callback, Function error_callback = nullptr); + void load_sync(const URL&, Function& response_headers)> success_callback, Function error_callback = nullptr); Function on_load_counter_change;