mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 20:15:17 +00:00
LibWeb: Ensure WebDriver response headers are exactly to spec
We must send a Cache-Control header, which then also requires that we respond with an HTTP/1.1 response (the Pragma cache option is HTTP/1.0). We should also send the Content-Type header using the same casing as is written in the WebDriver spec (lowercase). Both of these are explicitly tested by WPT.
This commit is contained in:
parent
7b3b608caf
commit
e436c31b97
Notes:
github-actions[bot]
2024-09-27 08:48:09 +00:00
Author: https://github.com/trflynn89 Commit: https://github.com/LadybirdBrowser/ladybird/commit/e436c31b97b Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1546 Reviewed-by: https://github.com/tcl3 ✅
1 changed files with 5 additions and 4 deletions
|
@ -293,13 +293,13 @@ ErrorOr<void, Client::WrappedError> Client::send_success_response(JsonValue resu
|
|||
auto content = result.serialized<StringBuilder>();
|
||||
|
||||
StringBuilder builder;
|
||||
builder.append("HTTP/1.0 200 OK\r\n"sv);
|
||||
builder.append("HTTP/1.1 200 OK\r\n"sv);
|
||||
builder.append("Server: WebDriver (SerenityOS)\r\n"sv);
|
||||
builder.append("X-Frame-Options: SAMEORIGIN\r\n"sv);
|
||||
builder.append("X-Content-Type-Options: nosniff\r\n"sv);
|
||||
builder.append("Pragma: no-cache\r\n"sv);
|
||||
if (keep_alive)
|
||||
builder.append("Connection: keep-alive\r\n"sv);
|
||||
builder.append("Cache-Control: no-cache\r\n"sv);
|
||||
builder.append("Content-Type: application/json; charset=utf-8\r\n"sv);
|
||||
builder.appendff("Content-Length: {}\r\n", content.length());
|
||||
builder.append("\r\n"sv);
|
||||
|
@ -334,8 +334,9 @@ ErrorOr<void, Client::WrappedError> Client::send_error_response(Error const& err
|
|||
result.serialize(content_builder);
|
||||
|
||||
StringBuilder header_builder;
|
||||
header_builder.appendff("HTTP/1.0 {} {}\r\n", error.http_status, reason);
|
||||
header_builder.append("Content-Type: application/json; charset=UTF-8\r\n"sv);
|
||||
header_builder.appendff("HTTP/1.1 {} {}\r\n", error.http_status, reason);
|
||||
header_builder.append("Cache-Control: no-cache\r\n"sv);
|
||||
header_builder.append("Content-Type: application/json; charset=utf-8\r\n"sv);
|
||||
header_builder.appendff("Content-Length: {}\r\n", content_builder.length());
|
||||
header_builder.append("\r\n"sv);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue