Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Content downloaded with fetch() API when Content-Encoding: gzip is se…
…t is not decompressed https://bugs.webkit.org/show_bug.cgi?id=247421 rdar://101935292 Reviewed by Brent Fulgham. In 195247@main we adopted CFNetwork SPI to opt-out of content encoding sniffing for XMLHttpRequest. Content encoding sniffing would cause responses with `Content-Encoding: gzip` and `Content-Type: application/octet-stream` to be treated as `Content-Type: application/gzip` and `Content-Encoding: identity` on macOS. The user and developer visible behavior is that the gzipped data is not decompressed. This brings that change forward to Fetch requests by setting the ContentEncodingSniffingPolicy flag in the FetchLoader. As an additional step this also renames the ContentEncodingSniffingPolicy flags to Default and Disable and replaces raw bools representing those flags with the enum itself. On iOS the flag has no effect since the default behavior is to opt-out of sniffing. * LayoutTests/platform/mac-wk1/TestExpectations: Skip new worker tests since workers are unsupported in WK1. * LayoutTests/imported/w3c/web-platform-tests/fetch/content-encoding/gzip-body.any-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/fetch/content-encoding/gzip-body.any.html: Added. * LayoutTests/imported/w3c/web-platform-tests/fetch/content-encoding/gzip-body.any.js: Added. (string_appeared_here.forEach.contentType.promise_test.async t): * LayoutTests/imported/w3c/web-platform-tests/fetch/content-encoding/gzip-body.any.serviceworker-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/fetch/content-encoding/gzip-body.any.serviceworker.html: Added. * LayoutTests/imported/w3c/web-platform-tests/fetch/content-encoding/gzip-body.any.sharedworker-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/fetch/content-encoding/gzip-body.any.sharedworker.html: Added. * LayoutTests/imported/w3c/web-platform-tests/fetch/content-encoding/gzip-body.any.worker-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/fetch/content-encoding/gzip-body.any.worker.html: Added. * LayoutTests/imported/w3c/web-platform-tests/fetch/content-encoding/resources/foo.octetstream.gz: Added. * LayoutTests/imported/w3c/web-platform-tests/fetch/content-encoding/resources/foo.octetstream.gz.headers: Added. * LayoutTests/imported/w3c/web-platform-tests/fetch/content-encoding/resources/foo.text.gz: Added. * LayoutTests/imported/w3c/web-platform-tests/fetch/content-encoding/resources/foo.text.gz.headers: Added. * Source/WebCore/Modules/fetch/FetchLoader.cpp: (WebCore::FetchLoader::start): * Source/WebCore/loader/ResourceLoader.cpp: (WebCore::ResourceLoader::start): * Source/WebCore/loader/ResourceLoader.h: (WebCore::ResourceLoader::contentEncodingSniffingPolicy const): (WebCore::ResourceLoader::shouldSniffContentEncoding const): Deleted. * Source/WebCore/loader/ResourceLoaderOptions.h: (WebCore::ResourceLoaderOptions::ResourceLoaderOptions): * Source/WebCore/loader/ThreadableLoader.cpp: (WebCore::ThreadableLoaderOptions::isolatedCopy const): * Source/WebCore/platform/network/BlobResourceHandle.cpp: (WebCore::BlobResourceHandle::BlobResourceHandle): * Source/WebCore/platform/network/ResourceHandle.cpp: (WebCore::ResourceHandle::ResourceHandle): (WebCore::ResourceHandle::create): (WebCore::ResourceHandle::contentEncodingSniffingPolicy const): (WebCore::ResourceHandle::shouldContentEncodingSniff const): Deleted. * Source/WebCore/platform/network/ResourceHandle.h: * Source/WebCore/platform/network/ResourceHandleInternal.h: (WebCore::ResourceHandleInternal::ResourceHandleInternal): * Source/WebCore/platform/network/cf/ResourceHandleCFNet.cpp: (WebCore::ResourceHandle::createCFURLConnection): (WebCore::ResourceHandle::start): (WebCore::ResourceHandle::platformLoadResourceSynchronously): * Source/WebCore/platform/network/curl/ResourceHandleCurl.cpp: (WebCore::ResourceHandle::platformLoadResourceSynchronously): * Source/WebCore/platform/network/mac/ResourceHandleMac.mm: (WebCore::ResourceHandle::applySniffingPoliciesIfNeeded): (WebCore::ResourceHandle::createNSURLConnection): (WebCore::ResourceHandle::start): (WebCore::ResourceHandle::platformLoadResourceSynchronously): * Source/WebCore/xml/XMLHttpRequest.cpp: (WebCore::XMLHttpRequest::createRequest): * Source/WebKit/NetworkProcess/NetworkLoadParameters.h: * Source/WebKit/NetworkProcess/ServiceWorker/ServiceWorkerSoftUpdateLoader.cpp: (WebKit::ServiceWorkerSoftUpdateLoader::loadFromNetwork): * Source/WebKit/NetworkProcess/cache/NetworkCacheSpeculativeLoad.cpp: (WebKit::NetworkCache::SpeculativeLoad::SpeculativeLoad): * Source/WebKit/NetworkProcess/cache/NetworkCacheSpeculativeLoadManager.cpp: (WebKit::NetworkCache::SpeculativeLoadManager::preconnectForSubresource): * Source/WebKit/NetworkProcess/cocoa/NetworkDataTaskCocoa.h: * Source/WebKit/NetworkProcess/cocoa/NetworkDataTaskCocoa.mm: (WebKit::NetworkDataTaskCocoa::applySniffingPoliciesAndBindRequestToInferfaceIfNeeded): (WebKit::NetworkDataTaskCocoa::NetworkDataTaskCocoa): * Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp: (WebKit::WebLoaderStrategy::scheduleLoadFromNetworkProcess): (WebKit::WebLoaderStrategy::loadResourceSynchronously): * Source/WebKitLegacy/WebCoreSupport/PingHandle.h: Canonical link: https://commits.webkit.org/256755@main
- Loading branch information
Showing
35 changed files
with
104 additions
and
63 deletions.
There are no files selected for viewing
4 changes: 4 additions & 0 deletions
4
...utTests/imported/w3c/web-platform-tests/fetch/content-encoding/gzip-body.any-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
PASS fetched gzip data with content type text should be decompressed. | ||
PASS fetched gzip data with content type octetstream should be decompressed. | ||
|
1 change: 1 addition & 0 deletions
1
LayoutTests/imported/w3c/web-platform-tests/fetch/content-encoding/gzip-body.any.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<!-- This file is required for WebKit test infrastructure to run the templated test --> |
16 changes: 16 additions & 0 deletions
16
LayoutTests/imported/w3c/web-platform-tests/fetch/content-encoding/gzip-body.any.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// META: global=window,worker | ||
|
||
const expectedDecompressedSize = 10500; | ||
[ | ||
"text", | ||
"octetstream" | ||
].forEach(contentType => { | ||
promise_test(async t => { | ||
let response = await fetch(`resources/foo.${contentType}.gz`); | ||
assert_true(response.ok); | ||
let arrayBuffer = await response.arrayBuffer() | ||
let u8 = new Uint8Array(arrayBuffer); | ||
assert_equals(u8.length, expectedDecompressedSize); | ||
}, `fetched gzip data with content type ${contentType} should be decompressed.`); | ||
}); | ||
|
4 changes: 4 additions & 0 deletions
4
...ed/w3c/web-platform-tests/fetch/content-encoding/gzip-body.any.serviceworker-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
PASS fetched gzip data with content type text should be decompressed. | ||
PASS fetched gzip data with content type octetstream should be decompressed. | ||
|
1 change: 1 addition & 0 deletions
1
...s/imported/w3c/web-platform-tests/fetch/content-encoding/gzip-body.any.serviceworker.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<!-- This file is required for WebKit test infrastructure to run the templated test --> |
4 changes: 4 additions & 0 deletions
4
...ted/w3c/web-platform-tests/fetch/content-encoding/gzip-body.any.sharedworker-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
PASS fetched gzip data with content type text should be decompressed. | ||
PASS fetched gzip data with content type octetstream should be decompressed. | ||
|
1 change: 1 addition & 0 deletions
1
...ts/imported/w3c/web-platform-tests/fetch/content-encoding/gzip-body.any.sharedworker.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<!-- This file is required for WebKit test infrastructure to run the templated test --> |
4 changes: 4 additions & 0 deletions
4
.../imported/w3c/web-platform-tests/fetch/content-encoding/gzip-body.any.worker-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
PASS fetched gzip data with content type text should be decompressed. | ||
PASS fetched gzip data with content type octetstream should be decompressed. | ||
|
1 change: 1 addition & 0 deletions
1
LayoutTests/imported/w3c/web-platform-tests/fetch/content-encoding/gzip-body.any.worker.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<!-- This file is required for WebKit test infrastructure to run the templated test --> |
Binary file added
BIN
+64 Bytes
...Tests/imported/w3c/web-platform-tests/fetch/content-encoding/resources/foo.octetstream.gz
Binary file not shown.
2 changes: 2 additions & 0 deletions
2
...ported/w3c/web-platform-tests/fetch/content-encoding/resources/foo.octetstream.gz.headers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Content-type: application/octet-stream | ||
Content-Encoding: gzip |
Binary file added
BIN
+57 Bytes
LayoutTests/imported/w3c/web-platform-tests/fetch/content-encoding/resources/foo.text.gz
Binary file not shown.
2 changes: 2 additions & 0 deletions
2
...ests/imported/w3c/web-platform-tests/fetch/content-encoding/resources/foo.text.gz.headers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Content-type: text/plain | ||
Content-Encoding: gzip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.