mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-30 04:39:06 +00:00
LibTLS+LibHTTP: Tolerate improperly closed TLS sockets
Some really cursed servers simply drop the TCP socket on the floor when they're trying to close an HTTP connection going through a TLS socket. This commit makes LibTLS tolerate these silly servers, and LibHTTP accept their idea of "EOF == connection closed". Fixes loading wpt.live/acid/acid3/test.html. Note that this means TLSv12::on_ready_to_read can fire with an empty buffer signifying EOF; one test refused this behaviour, and has been changed in this commit.
This commit is contained in:
parent
2d90317c20
commit
06386ab2b5
Notes:
sideshowbarker
2024-07-19 16:49:21 +09:00
Author: https://github.com/alimpfard 🔰
Commit: 06386ab2b5
Pull-request: https://github.com/SerenityOS/serenity/pull/23981
3 changed files with 32 additions and 8 deletions
|
@ -223,8 +223,20 @@ void Job::on_socket_connected()
|
|||
}
|
||||
|
||||
if (m_socket->is_eof()) {
|
||||
dbgln_if(JOB_DEBUG, "Read failure: Actually EOF!");
|
||||
return deferred_invoke([this] { did_fail(Core::NetworkJob::Error::ProtocolFailed); });
|
||||
// Some servers really like terminating connections by simply closing them (even TLS ones)
|
||||
// to signal end-of-data, if there's no:
|
||||
// - connection
|
||||
// - content-size
|
||||
// - transfer-encoding: chunked
|
||||
// header, simply treat EOF as a termination signal.
|
||||
if (m_headers.contains("connection"sv) || m_content_length.has_value() || m_current_chunk_total_size.has_value()) {
|
||||
dbgln_if(JOB_DEBUG, "Read failure: Actually EOF!");
|
||||
deferred_invoke([this] { did_fail(Core::NetworkJob::Error::ProtocolFailed); });
|
||||
return;
|
||||
}
|
||||
|
||||
finish_up();
|
||||
return;
|
||||
}
|
||||
|
||||
while (m_state == State::InStatus) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue