diff options
author | Andreas Kling <kling@serenityos.org> | 2020-09-28 11:55:26 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-09-28 11:55:26 +0200 |
commit | 2946a684efd1d3c34148d16121b118574b6a9132 (patch) | |
tree | 0c541334f692056dda692329d781979a18693ceb /Libraries/LibProtocol | |
parent | cfafd4d52da0ce04231cdeadc93a9d6764cceb8b (diff) | |
download | serenity-2946a684efd1d3c34148d16121b118574b6a9132.zip |
ProtocolServer+LibWeb: Support more detailed HTTP requests
This patch adds the ability for ProtocolServer clients to specify which
HTTP method to use, and also to include an optional HTTP request body.
Diffstat (limited to 'Libraries/LibProtocol')
-rw-r--r-- | Libraries/LibProtocol/Client.cpp | 4 | ||||
-rw-r--r-- | Libraries/LibProtocol/Client.h | 2 |
2 files changed, 3 insertions, 3 deletions
diff --git a/Libraries/LibProtocol/Client.cpp b/Libraries/LibProtocol/Client.cpp index 3531bfaa76..0138ed9349 100644 --- a/Libraries/LibProtocol/Client.cpp +++ b/Libraries/LibProtocol/Client.cpp @@ -47,13 +47,13 @@ bool Client::is_supported_protocol(const String& protocol) return send_sync<Messages::ProtocolServer::IsSupportedProtocol>(protocol)->supported(); } -RefPtr<Download> Client::start_download(const String& url, const HashMap<String, String>& request_headers) +RefPtr<Download> Client::start_download(const String& method, const String& url, const HashMap<String, String>& request_headers, const ByteBuffer& request_body) { IPC::Dictionary header_dictionary; for (auto& it : request_headers) header_dictionary.add(it.key, it.value); - i32 download_id = send_sync<Messages::ProtocolServer::StartDownload>(url, header_dictionary)->download_id(); + i32 download_id = send_sync<Messages::ProtocolServer::StartDownload>(method, url, header_dictionary, String::copy(request_body))->download_id(); if (download_id < 0) return nullptr; auto download = Download::create_from_id({}, *this, download_id); diff --git a/Libraries/LibProtocol/Client.h b/Libraries/LibProtocol/Client.h index 6724a30779..ca9f93b3e6 100644 --- a/Libraries/LibProtocol/Client.h +++ b/Libraries/LibProtocol/Client.h @@ -44,7 +44,7 @@ public: virtual void handshake() override; bool is_supported_protocol(const String&); - RefPtr<Download> start_download(const String& url, const HashMap<String, String>& request_headers = {}); + RefPtr<Download> start_download(const String& method, const String& url, const HashMap<String, String>& request_headers = {}, const ByteBuffer& request_body = {}); bool stop_download(Badge<Download>, Download&); bool set_certificate(Badge<Download>, Download&, String, String); |