mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-20 19:45:12 +00:00
Merge 3b5ff3dd64
into 8e37cd2f71
This commit is contained in:
commit
57e9021f8b
3 changed files with 21 additions and 2 deletions
|
@ -19,7 +19,8 @@ enum class NetworkError {
|
|||
SSLHandshakeFailed,
|
||||
SSLVerificationFailed,
|
||||
MalformedUrl,
|
||||
Unknown
|
||||
InvalidContentEncoding,
|
||||
Unknown,
|
||||
};
|
||||
|
||||
constexpr StringView network_error_to_string(NetworkError network_error)
|
||||
|
@ -41,6 +42,8 @@ constexpr StringView network_error_to_string(NetworkError network_error)
|
|||
return "SSL verification failed"sv;
|
||||
case NetworkError::MalformedUrl:
|
||||
return "The URL is not formatted properly"sv;
|
||||
case NetworkError::InvalidContentEncoding:
|
||||
return "Response could not be decoded with its Content-Encoding"sv;
|
||||
case NetworkError::Unknown:
|
||||
return "An unexpected network error occurred"sv;
|
||||
}
|
||||
|
|
|
@ -2470,17 +2470,24 @@ WebIDL::ExceptionOr<GC::Ref<PendingResponse>> nonstandard_resource_loader_file_o
|
|||
} else {
|
||||
response->set_type(Infrastructure::Response::Type::Error);
|
||||
response->set_status(status_code.value_or(400));
|
||||
|
||||
auto [body, _] = TRY_OR_IGNORE(extract_body(realm, data));
|
||||
response->set_body(move(body));
|
||||
response->set_body(body);
|
||||
|
||||
auto body_info = response->body_info();
|
||||
body_info.encoded_size = timing_info.encoded_body_size;
|
||||
body_info.decoded_size = data.size();
|
||||
response->set_body_info(body_info);
|
||||
|
||||
for (auto const& [name, value] : response_headers.headers()) {
|
||||
auto header = Infrastructure::Header::from_latin1_pair(name, value);
|
||||
response->header_list()->append(move(header));
|
||||
}
|
||||
|
||||
// 16.1.2.2. Otherwise, if stream is readable, error stream with a TypeError.
|
||||
if (body->stream()->is_readable())
|
||||
body->stream()->error(JS::TypeError::create(realm, error));
|
||||
|
||||
if (reason_phrase.has_value())
|
||||
response->set_status_message(MUST(ByteBuffer::copy(reason_phrase.value().bytes())));
|
||||
}
|
||||
|
|
|
@ -527,6 +527,8 @@ static Requests::NetworkError map_curl_code_to_network_error(CURLcode const& cod
|
|||
return Requests::NetworkError::SSLVerificationFailed;
|
||||
case CURLE_URL_MALFORMAT:
|
||||
return Requests::NetworkError::MalformedUrl;
|
||||
case CURLE_BAD_CONTENT_ENCODING:
|
||||
return Requests::NetworkError::InvalidContentEncoding;
|
||||
default:
|
||||
return Requests::NetworkError::Unknown;
|
||||
}
|
||||
|
@ -631,6 +633,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) {
|
||||
|
|
Loading…
Add table
Reference in a new issue