From 2e81990a3c3fc3a0d6da56d801d082240c1ccf2f Mon Sep 17 00:00:00 2001 From: Brian Gianforcaro Date: Tue, 8 Feb 2022 23:39:30 -0800 Subject: [PATCH] LibWeb: Do not set Content-Length headers twice for POST requests While trying to get http://lite.duckduckgo.com to work in the Browser I noticed that we kept on getting 400 (Bad Request) errors when you click the "Search" button for a request. After turning on `JOB_DEBUG` to see what headers we were sending it turned out that we were actually setting `Content-Length` twice once in LibWeb, and again when the request is handled by LibHTTP. Since LibHTTP transparently handles this now, we can avoid it in LibWeb. --- Userland/Libraries/LibWeb/HTML/HTMLFormElement.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/Userland/Libraries/LibWeb/HTML/HTMLFormElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLFormElement.cpp index 3dac65925f..db8d71abc3 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLFormElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLFormElement.cpp @@ -117,7 +117,6 @@ void HTMLFormElement::submit_form(RefPtr submitter, bool from_submi auto body = url_encode(parameters, AK::URL::PercentEncodeSet::ApplicationXWWWFormUrlencoded).to_byte_buffer(); request.set_method("POST"); request.set_header("Content-Type", "application/x-www-form-urlencoded"); - request.set_header("Content-Length", String::number(body.size())); request.set_body(body); }