Bug 175764 - Fetch: data: URL HEAD request should result in empty response body
Summary: Fetch: data: URL HEAD request should result in empty response body
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Rob Buis
URL:
Keywords: InRadar
: 201136 (view as bug list)
Depends on:
Blocks:
 
Reported: 2017-08-21 03:09 PDT by Anne van Kesteren
Modified: 2019-10-08 05:52 PDT (History)
9 users (show)

See Also:


Attachments
Patch (4.23 KB, patch)
2019-10-05 01:08 PDT, Rob Buis
no flags Details | Formatted Diff | Diff
Patch (5.25 KB, patch)
2019-10-05 01:45 PDT, Rob Buis
no flags Details | Formatted Diff | Diff
Patch (5.25 KB, patch)
2019-10-05 04:36 PDT, Rob Buis
no flags Details | Formatted Diff | Diff
Patch (4.38 KB, patch)
2019-10-08 00:32 PDT, Rob Buis
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Anne van Kesteren 2017-08-21 03:09:54 PDT
Test: http://w3c-test.org/XMLHttpRequest/data-uri.htm

Updated in: https://github.com/w3c/web-platform-tests/pull/6923

Even if Fetch initially ends up creating a response with a body, main fetch step 18 sets it to null again. This is my bad since it's likely you used to pass this.
Comment 1 youenn fablet 2019-08-28 00:40:49 PDT
This is probably easy to fix and makes sense to me.

Looking at https://wpt.fyi/results/fetch/api/basic/scheme-data.any.html?label=master&label=experimental&aligned&q=fetch%2Fapi%2Fbasic%2Fscheme-data.any.html, all browsers consistently provide a body to HEAD data URL requests when using fetch API.

Looking at https://wpt.fyi/results/xhr/data-uri.htm?label=master&label=experimental&aligned&q=xhr%2Fdata-uri.htm, all browsers except Firefox do so when using XHR.
Comment 2 Rob Buis 2019-10-05 01:08:28 PDT
Created attachment 380279 [details]
Patch
Comment 3 Rob Buis 2019-10-05 01:45:22 PDT
Created attachment 380280 [details]
Patch
Comment 4 Rob Buis 2019-10-05 04:36:16 PDT
Created attachment 380281 [details]
Patch
Comment 5 youenn fablet 2019-10-07 11:46:50 PDT
Comment on attachment 380281 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=380281&action=review

> Source/WebCore/ChangeLog:11
> +               imported/web-platform-tests/xhr/data-uri.html

Can we update ResourceLoader::loadDataURL()?
Comment 6 Rob Buis 2019-10-08 00:32:04 PDT
Created attachment 380410 [details]
Patch
Comment 7 Rob Buis 2019-10-08 03:42:19 PDT
(In reply to youenn fablet from comment #5)
> Comment on attachment 380281 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=380281&action=review
> 
> > Source/WebCore/ChangeLog:11
> > +               imported/web-platform-tests/xhr/data-uri.html
> 
> Can we update ResourceLoader::loadDataURL()?

That does seem like the better spot to fix this for data url's, done.
Comment 8 youenn fablet 2019-10-08 03:58:23 PDT
Comment on attachment 380410 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=380410&action=review

> Source/WebCore/loader/ResourceLoader.cpp:288
> +            if (!this->reachedTerminalState() && dataSize && m_request.httpMethod() != "HEAD")

I believe we correctly handle these cases but do we have test coverage for gEt or HeAD?

As a side-note, we probably currently fail HEAD requests for blobs.
Are we expected to also do the same as for data URLs?

Since no HEAD request is expected to give a response with a body, I guess we could add an ASSERT in DocumentThreadableLoader to ensure that.
Comment 9 Rob Buis 2019-10-08 05:04:19 PDT
(In reply to youenn fablet from comment #8)
> Comment on attachment 380410 [details]
> I believe we correctly handle these cases but do we have test coverage for
> gEt or HeAD?

I don't think there are tests, I quickly tried it locally on data-uri.htm and indeed we handle it correctly.

> As a side-note, we probably currently fail HEAD requests for blobs.
> Are we expected to also do the same as for data URLs?

IIUC according to the spec we should not even support anything other than GET:
https://fetch.spec.whatwg.org/#concept-scheme-fetch (blob 1.2)
However AFAIK chromium and WebKit do support HEAD. So this seems a grey area.

> Since no HEAD request is expected to give a response with a body, I guess we
> could add an ASSERT in DocumentThreadableLoader to ensure that.

We could, I will keep it in mind since there may be more bugs/tests that would require it.
Comment 10 Rob Buis 2019-10-08 05:06:26 PDT
*** Bug 201136 has been marked as a duplicate of this bug. ***
Comment 11 WebKit Commit Bot 2019-10-08 05:51:43 PDT
Comment on attachment 380410 [details]
Patch

Clearing flags on attachment: 380410

Committed r250822: <https://trac.webkit.org/changeset/250822>
Comment 12 WebKit Commit Bot 2019-10-08 05:51:45 PDT
All reviewed patches have been landed.  Closing bug.
Comment 13 Radar WebKit Bug Importer 2019-10-08 05:52:17 PDT
<rdar://problem/56071479>