Truly independent web browser
RequestServer: Expose responses before reporting decoding errors
Andreas Kling36b8ceb10220
diff --git a/Services/RequestServer/Request.cpp b/Services/RequestServer/Request.cppindex d05871ef1c8..2c92b827094 100644--- a/Services/RequestServer/Request.cpp+++ b/Services/RequestServer/Request.cpp@@ -853,6 +853,16 @@ void Request::handle_fetch_complete(int result_code)transfer_headers_to_client_if_needed();}+ // https://fetch.spec.whatwg.org/#concept-http-network-fetch+ // 11. If bytes is failure, then terminate fetchParams’s controller.+ // NB: A decoding failure is a body error after the response headers arrived. Expose that response even if libcurl+ // could not produce a single decoded byte, after storing its cookies and HSTS policy.+ if (result_code == CURLE_BAD_CONTENT_ENCODING) {+ if (defer_until_response_cookies_and_hsts_policy_are_stored([this, result_code] { handle_fetch_complete(result_code); }))+ return;+ transfer_headers_to_client_if_needed();+ }+m_curl_result_code = result_code;if (m_response_buffer.is_eof())diff --git a/Tests/LibWeb/Text/expected/Fetch/malformed-content-encoding-cookies.txt b/Tests/LibWeb/Text/expected/Fetch/malformed-content-encoding-cookies.txtindex 3adc7e7c258..cbf645a4286 100644--- a/Tests/LibWeb/Text/expected/Fetch/malformed-content-encoding-cookies.txt+++ b/Tests/LibWeb/Text/expected/Fetch/malformed-content-encoding-cookies.txt@@ -1,2 +1,6 @@-GET fetch: TypeError-POST fetch: TypeError+GET status: 200+GET body: TypeError+GET cookie stored: true+POST status: 200+POST body: TypeError+POST cookie stored: truediff --git a/Tests/LibWeb/Text/expected/wpt-import/fetch/content-encoding/br/bad-br-body.https.any.txt b/Tests/LibWeb/Text/expected/wpt-import/fetch/content-encoding/br/bad-br-body.https.any.txtindex ea864f79100..2f5985587d1 100644--- a/Tests/LibWeb/Text/expected/wpt-import/fetch/content-encoding/br/bad-br-body.https.any.txt+++ b/Tests/LibWeb/Text/expected/wpt-import/fetch/content-encoding/br/bad-br-body.https.any.txt@@ -2,10 +2,10 @@ Harness status: OKFound 6 tests-6 Fail-Fail Consuming the body of a resource with bad br content with arrayBuffer() should reject-Fail Consuming the body of a resource with bad br content with blob() should reject-Fail Consuming the body of a resource with bad br content with bytes() should reject-Fail Consuming the body of a resource with bad br content with formData() should reject-Fail Consuming the body of a resource with bad br content with json() should reject-Fail Consuming the body of a resource with bad br content with text() should reject\ No newline at end of file+6 Pass+Pass Consuming the body of a resource with bad br content with arrayBuffer() should reject+Pass Consuming the body of a resource with bad br content with blob() should reject+Pass Consuming the body of a resource with bad br content with bytes() should reject+Pass Consuming the body of a resource with bad br content with formData() should reject+Pass Consuming the body of a resource with bad br content with json() should reject+Pass Consuming the body of a resource with bad br content with text() should reject\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/fetch/content-encoding/gzip/bad-gzip-body.any.txt b/Tests/LibWeb/Text/expected/wpt-import/fetch/content-encoding/gzip/bad-gzip-body.any.txtindex f1c2448fd14..06e635932b7 100644--- a/Tests/LibWeb/Text/expected/wpt-import/fetch/content-encoding/gzip/bad-gzip-body.any.txt+++ b/Tests/LibWeb/Text/expected/wpt-import/fetch/content-encoding/gzip/bad-gzip-body.any.txt@@ -2,11 +2,11 @@ Harness status: OKFound 7 tests-7 Fail-Fail Fetching a resource with bad gzip content should still resolve-Fail Consuming the body of a resource with bad gzip content with arrayBuffer() should reject-Fail Consuming the body of a resource with bad gzip content with blob() should reject-Fail Consuming the body of a resource with bad gzip content with bytes() should reject-Fail Consuming the body of a resource with bad gzip content with formData() should reject-Fail Consuming the body of a resource with bad gzip content with json() should reject-Fail Consuming the body of a resource with bad gzip content with text() should reject\ No newline at end of file+7 Pass+Pass Fetching a resource with bad gzip content should still resolve+Pass Consuming the body of a resource with bad gzip content with arrayBuffer() should reject+Pass Consuming the body of a resource with bad gzip content with blob() should reject+Pass Consuming the body of a resource with bad gzip content with bytes() should reject+Pass Consuming the body of a resource with bad gzip content with formData() should reject+Pass Consuming the body of a resource with bad gzip content with json() should reject+Pass Consuming the body of a resource with bad gzip content with text() should reject\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/fetch/content-encoding/zstd/bad-zstd-body.https.any.txt b/Tests/LibWeb/Text/expected/wpt-import/fetch/content-encoding/zstd/bad-zstd-body.https.any.txtindex 0719ad6aa41..c37170dffd3 100644--- a/Tests/LibWeb/Text/expected/wpt-import/fetch/content-encoding/zstd/bad-zstd-body.https.any.txt+++ b/Tests/LibWeb/Text/expected/wpt-import/fetch/content-encoding/zstd/bad-zstd-body.https.any.txt@@ -2,11 +2,11 @@ Harness status: OKFound 7 tests-7 Fail-Fail Fetching a resource with bad zstd content should still resolve-Fail Consuming the body of a resource with bad zstd content with arrayBuffer() should reject-Fail Consuming the body of a resource with bad zstd content with blob() should reject-Fail Consuming the body of a resource with bad zstd content with bytes() should reject-Fail Consuming the body of a resource with bad zstd content with formData() should reject-Fail Consuming the body of a resource with bad zstd content with json() should reject-Fail Consuming the body of a resource with bad zstd content with text() should reject\ No newline at end of file+7 Pass+Pass Fetching a resource with bad zstd content should still resolve+Pass Consuming the body of a resource with bad zstd content with arrayBuffer() should reject+Pass Consuming the body of a resource with bad zstd content with blob() should reject+Pass Consuming the body of a resource with bad zstd content with bytes() should reject+Pass Consuming the body of a resource with bad zstd content with formData() should reject+Pass Consuming the body of a resource with bad zstd content with json() should reject+Pass Consuming the body of a resource with bad zstd content with text() should reject\ No newline at end of file