mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 06:17:35 +00:00
LibHTTP: Exit the read loop early when there cannot be any further data
This commit is contained in:
parent
6819193671
commit
c5d7eb8618
1 changed files with 8 additions and 0 deletions
|
@ -175,6 +175,14 @@ void Job::on_socket_connected()
|
|||
on_headers_received(m_headers, m_code > 0 ? m_code : Optional<u32> {});
|
||||
m_state = State::InBody;
|
||||
}
|
||||
|
||||
// We've reached the end of the headers, there's a possibility that the server
|
||||
// responds with nothing (content-length = 0 with normal encoding); if that's the case,
|
||||
// quit early as we won't be reading anything anyway.
|
||||
if (auto result = m_headers.get("Content-Length"sv).value_or(""sv).to_uint(); result.has_value()) {
|
||||
if (result.value() == 0 && !m_headers.get("Transfer-Encoding"sv).value_or(""sv).view().trim_whitespace().equals_ignoring_case("chunked"sv))
|
||||
return finish_up();
|
||||
}
|
||||
return;
|
||||
}
|
||||
auto parts = line.split_view(':');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue