mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-25 10:48:41 +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:
@@ -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 });
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user