Bug 228085 - FetchResponse.formData() should not reject promise if the body is null and the MIME Type is "application/x-www-form-urlencoded"
Summary: FetchResponse.formData() should not reject promise if the body is null and th...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Page Loading (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Chris Dumez
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-07-19 12:49 PDT by Chris Dumez
Modified: 2021-07-19 14:34 PDT (History)
6 users (show)

See Also:


Attachments
Patch (10.86 KB, patch)
2021-07-19 12:52 PDT, Chris Dumez
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Patch (10.86 KB, patch)
2021-07-19 12:56 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (10.92 KB, patch)
2021-07-19 13:06 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Dumez 2021-07-19 12:49:56 PDT
FetchResponse.formData() should not reject promise if the body is null and the MIME Type is "application/x-www-form-urlencoded":
- https://fetch.spec.whatwg.org/#concept-body-consume-body
- https://fetch.spec.whatwg.org/#concept-body-package-data

As per the specification, we should package an empty byte sequence in this case and resolve the promise with that.
Comment 1 Chris Dumez 2021-07-19 12:52:04 PDT
Created attachment 433813 [details]
Patch
Comment 2 Chris Dumez 2021-07-19 12:56:32 PDT
Created attachment 433814 [details]
Patch
Comment 3 Alex Christensen 2021-07-19 13:02:43 PDT
Comment on attachment 433814 [details]
Patch

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

> Source/WebCore/Modules/fetch/FetchBodyOwner.cpp:195
> +    if (isBodyNullOrOpaque()) {
> +        // If the content-type is 'application/x-www-form-urlencoded', a body is not required and we should package an empty byte sequence as per the specification.

It seems like we should only do this for isBodyNull
Comment 4 Chris Dumez 2021-07-19 13:06:07 PDT
Created attachment 433815 [details]
Patch
Comment 5 Chris Dumez 2021-07-19 13:06:33 PDT
(In reply to Alex Christensen from comment #3)
> Comment on attachment 433814 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=433814&action=review
> 
> > Source/WebCore/Modules/fetch/FetchBodyOwner.cpp:195
> > +    if (isBodyNullOrOpaque()) {
> > +        // If the content-type is 'application/x-www-form-urlencoded', a body is not required and we should package an empty byte sequence as per the specification.
> 
> It seems like we should only do this for isBodyNull

Good point, the spec only mentions the body being null.
Comment 6 Chris Dumez 2021-07-19 13:21:18 PDT
Why the r-??
Comment 7 Alex Christensen 2021-07-19 13:21:55 PDT
isBodyNullOrOpaque needs to be changed to isBodyNull
Comment 8 Chris Dumez 2021-07-19 13:22:37 PDT
Comment on attachment 433815 [details]
Patch

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

> Source/WebCore/Modules/fetch/FetchBodyOwner.cpp:195
> +        if (isBodyNull()) {

It does check isBodyNull()... ?
Comment 9 Alex Christensen 2021-07-19 13:23:38 PDT
Comment on attachment 433815 [details]
Patch

Oh, I didn't see that there was a new patch.  Sorry
Comment 10 EWS 2021-07-19 14:33:24 PDT
Committed r280046 (239781@main): <https://commits.webkit.org/239781@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 433815 [details].
Comment 11 Radar WebKit Bug Importer 2021-07-19 14:34:24 PDT
<rdar://problem/80802980>