mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-31 21:29:06 +00:00
LibTLS: Ignore empty reads from underlying socket while connecting
We should not expect the server to respond immediately after connecting, this can manifest as random requests failing (e.g. on https://null.com).
This commit is contained in:
parent
6f90495512
commit
2f10243fa2
Notes:
sideshowbarker
2024-07-17 22:41:14 +09:00
Author: https://github.com/alimpfard
Commit: 2f10243fa2
Pull-request: https://github.com/SerenityOS/serenity/pull/24120
2 changed files with 4 additions and 1 deletions
|
@ -66,6 +66,7 @@ ErrorOr<NonnullOwnPtr<TLSv12>> TLSv12::connect(ByteString const& host, u16 port,
|
|||
};
|
||||
|
||||
TRY(promise->await());
|
||||
tls_socket->m_context.should_expect_successful_read = true;
|
||||
return tls_socket;
|
||||
}
|
||||
|
||||
|
@ -83,6 +84,7 @@ ErrorOr<NonnullOwnPtr<TLSv12>> TLSv12::connect(ByteString const& host, Core::Soc
|
|||
promise->reject(AK::Error::from_string_view(enum_to_string(alert)));
|
||||
};
|
||||
TRY(promise->await());
|
||||
tls_socket->m_context.should_expect_successful_read = true;
|
||||
return tls_socket;
|
||||
}
|
||||
|
||||
|
@ -174,7 +176,7 @@ ErrorOr<void> TLSv12::read_from_socket()
|
|||
consume(read_bytes);
|
||||
} while (!read_bytes.is_empty() && !m_context.critical_error);
|
||||
|
||||
if (read_bytes.is_empty()) {
|
||||
if (m_context.should_expect_successful_read && read_bytes.is_empty()) {
|
||||
// read_some() returned an empty span, this is either an EOF (from improper closure)
|
||||
// or some sort of weird even that is showing itself as an EOF.
|
||||
// To guard against servers closing the connection weirdly or just improperly, make sure
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue