RequestServer: Ignore CURLE_RECV_ERROR in some cases

The HTTPS server used by WPT will close TLS connections without sending
a "close notify" alert. For responses that did not have a Content-Length
header, curl treats this as an error.
This commit is contained in:
Timothy Flynn 2025-04-19 16:03:41 -04:00
parent 8e37cd2f71
commit ebe85338b7

View file

@ -631,6 +631,13 @@ void ConnectionFromClient::check_active_requests()
auto result_code = msg->data.result;
// HTTPS servers might terminate their connection without proper notice of shutdown - i.e. they do not send
// a "close notify" alert. OpenSSL version 3.2 began treating this as an error, which curl translates to
// CURLE_RECV_ERROR in the absence of a Content-Length response header. The Python server used by WPT is one
// such server. We ignore this error if we were actually able to download some response data.
if (result_code == CURLE_RECV_ERROR && request->downloaded_so_far != 0 && !request->headers.contains("Content-Length"sv))
result_code = CURLE_OK;
Optional<Requests::NetworkError> network_error;
bool const request_was_successful = result_code == CURLE_OK;
if (!request_was_successful) {