summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibHTTP
diff options
context:
space:
mode:
authorAli Mohammad Pur <ali.mpfard@gmail.com>2022-02-09 23:21:17 +0330
committerAndreas Kling <kling@serenityos.org>2022-02-09 21:23:25 +0100
commit9ff22ac7e04b40b5cfdd7920d798e9c953c1d2c8 (patch)
tree37f0a41818e2a4f4d0f752d499a3a4bc6e134dd6 /Userland/Libraries/LibHTTP
parentcb7becb0671ae2ca435384b0133b484e495a2af2 (diff)
downloadserenity-9ff22ac7e04b40b5cfdd7920d798e9c953c1d2c8.zip
LibHTTP: Skip the body when response code is 204
...even if the headers claim that there's some data in the form of Content-Length. This finally fixes loading Discord with RequestServer ConnectionCache on :^)
Diffstat (limited to 'Userland/Libraries/LibHTTP')
-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 8ac31ee412..52004cda26 100644
--- a/Userland/Libraries/LibHTTP/Job.cpp
+++ b/Userland/Libraries/LibHTTP/Job.cpp
@@ -310,6 +310,11 @@ void Job::on_socket_connected()
if (result.value() == 0 && !m_headers.get("Transfer-Encoding"sv).value_or(""sv).view().trim_whitespace().equals_ignoring_case("chunked"sv))
return finish_up();
}
+ // There's also the possibility that the server responds with 204 (No Content),
+ // and manages to set a Content-Length anyway, in such cases ignore Content-Length and quit early;
+ // As the HTTP spec explicitly prohibits presence of Content-Length when the response code is 204.
+ if (m_code == 204)
+ return finish_up();
can_read_line = m_socket->can_read_line();
if (can_read_line.is_error())