summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorKarol Kosek <krkk@serenityos.org>2021-10-16 20:17:29 +0200
committerAndreas Kling <kling@serenityos.org>2021-10-24 23:54:26 +0200
commit78bebb363b7a284be6f306a83072080e78c36d85 (patch)
treecc6122f2dc0b79d4b1eada1eaa7d2f210ff58c7b /Userland
parent89c87ff7b9eaf88bccf7e63419c4be79d0812184 (diff)
downloadserenity-78bebb363b7a284be6f306a83072080e78c36d85.zip
LibHTTP: Reset m_content_length if there's a Transfer-Encoding header
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibHTTP/Job.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/Userland/Libraries/LibHTTP/Job.cpp b/Userland/Libraries/LibHTTP/Job.cpp
index c690bd067d..8043254861 100644
--- a/Userland/Libraries/LibHTTP/Job.cpp
+++ b/Userland/Libraries/LibHTTP/Job.cpp
@@ -288,6 +288,11 @@ void Job::on_socket_connected()
} else {
auto transfer_encoding = m_headers.get("Transfer-Encoding");
if (transfer_encoding.has_value()) {
+ // HTTP/1.1 3.3.3.3:
+ // If a message is received with both a Transfer-Encoding and a Content-Length header field, the Transfer-Encoding overrides the Content-Length. [...]
+ // https://httpwg.org/specs/rfc7230.html#message.body.length
+ m_content_length = {};
+
// Note: Some servers add extra spaces around 'chunked', see #6302.
auto encoding = transfer_encoding.value().trim_whitespace();