mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-26 22:38:51 +00:00
ProtocolServer: Support request headers
You can now pass a dictionary of request headers when starting a new download in ProtocolServer. The HTTP and HTTPS protocol will include the headers in their requests.
This commit is contained in:
parent
25cfdf3f67
commit
897998017a
Notes:
sideshowbarker
2024-07-19 06:17:37 +09:00
Author: https://github.com/awesomekling
Commit: 897998017a
13 changed files with 35 additions and 13 deletions
|
@ -71,7 +71,14 @@ ByteBuffer HttpRequest::to_raw_request() const
|
|||
}
|
||||
builder.append(" HTTP/1.1\r\nHost: ");
|
||||
builder.append(m_url.host());
|
||||
builder.append("\r\nConnection: close\r\n\r\n");
|
||||
builder.append("\r\n");
|
||||
for (auto& header : m_headers) {
|
||||
builder.append(header.name);
|
||||
builder.append(": ");
|
||||
builder.append(header.value);
|
||||
builder.append("\r\n");
|
||||
}
|
||||
builder.append("Connection: close\r\n\r\n");
|
||||
return builder.to_byte_buffer();
|
||||
}
|
||||
|
||||
|
@ -181,4 +188,10 @@ Optional<HttpRequest> HttpRequest::from_raw_request(const ByteBuffer& raw_reques
|
|||
return request;
|
||||
}
|
||||
|
||||
void HttpRequest::set_headers(const HashMap<String,String>& headers)
|
||||
{
|
||||
for (auto& it : headers)
|
||||
m_headers.append({ it.key, it.value });
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue