Bug 162667 - [Fetch API] Add support for URLSearchParams body
Summary: [Fetch API] Add support for URLSearchParams body
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: youenn fablet
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-09-28 02:21 PDT by youenn fablet
Modified: 2016-10-06 03:58 PDT (History)
5 users (show)

See Also:


Attachments
Patch (35.87 KB, patch)
2016-09-28 03:53 PDT, youenn fablet
no flags Details | Formatted Diff | Diff
Patch for landing (35.03 KB, patch)
2016-09-30 00:10 PDT, youenn fablet
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description youenn fablet 2016-09-28 02:21:14 PDT
We should support URLSearchParams bodies as per https://fetch.spec.whatwg.org/#body-mixin
Comment 1 youenn fablet 2016-09-28 03:53:44 PDT
Created attachment 290073 [details]
Patch
Comment 2 Alex Christensen 2016-09-28 08:25:16 PDT
Comment on attachment 290073 [details]
Patch

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

> Source/WebCore/Modules/fetch/FetchBody.cpp:53
> +    CString data = text.utf8();

Is this correct? I think there should be a test with an emoji in it.

> Source/WebCore/Modules/fetch/FetchBody.cpp:95
> +    , m_contentType(ASCIILiteral("application/x-www-form-urlencoded;charset=UTF-8"))

This string exists in many places in WebCore, all of them so far without the charset.  There should be a common place for this const char[] definition somewhere.
Comment 3 youenn fablet 2016-09-28 09:32:24 PDT
Comment on attachment 290073 [details]
Patch

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

>> Source/WebCore/Modules/fetch/FetchBody.cpp:53
>> +    CString data = text.utf8();
> 
> Is this correct? I think there should be a test with an emoji in it.

Good point, there is no test for that.
I plan to fix the double allocation by moving this function in WTFString.
Can it be tackled at that time?

>> Source/WebCore/Modules/fetch/FetchBody.cpp:95
>> +    , m_contentType(ASCIILiteral("application/x-www-form-urlencoded;charset=UTF-8"))
> 
> This string exists in many places in WebCore, all of them so far without the charset.  There should be a common place for this const char[] definition somewhere.

Sounds good, how about adding in a future patch common HTTP header values in Source/WebCore/platform/, like in a new file like network/HTTPHeaderValues.*.
Comment 4 Alex Christensen 2016-09-28 12:19:25 PDT
(In reply to comment #3)
> Comment on attachment 290073 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=290073&action=review
> 
> >> Source/WebCore/Modules/fetch/FetchBody.cpp:53
> >> +    CString data = text.utf8();
> > 
> > Is this correct? I think there should be a test with an emoji in it.
> 
> Good point, there is no test for that.
> I plan to fix the double allocation by moving this function in WTFString.
> Can it be tackled at that time?
I think this should be done in the same patch so we don't have incorrect behavior in trunk. 
> 
> >> Source/WebCore/Modules/fetch/FetchBody.cpp:95
> >> +    , m_contentType(ASCIILiteral("application/x-www-form-urlencoded;charset=UTF-8"))
> > 
> > This string exists in many places in WebCore, all of them so far without the charset.  There should be a common place for this const char[] definition somewhere.
> 
> Sounds good, how about adding in a future patch common HTTP header values in
> Source/WebCore/platform/, like in a new file like network/HTTPHeaderValues.*.
Sure. Different patch ok.
Comment 5 youenn fablet 2016-09-28 12:22:28 PDT
This behavior is already in the repository... This patch is only moving the code we are talking from method to function.
Comment 6 Alex Christensen 2016-09-28 20:32:11 PDT
Comment on attachment 290073 [details]
Patch

Dang it, you're right.  This doesn't make things worse
Comment 7 Alex Christensen 2016-09-28 21:52:10 PDT
We really ought to fix it soon, though.  Add a FIXME saying that it might not do the right thing with unicode characters.
Comment 8 youenn fablet 2016-09-30 00:10:41 PDT
Created attachment 290308 [details]
Patch for landing
Comment 9 WebKit Commit Bot 2016-09-30 01:07:15 PDT
Comment on attachment 290308 [details]
Patch for landing

Clearing flags on attachment: 290308

Committed r206632: <http://trac.webkit.org/changeset/206632>
Comment 10 WebKit Commit Bot 2016-09-30 01:07:20 PDT
All reviewed patches have been landed.  Closing bug.
Comment 11 youenn fablet 2016-09-30 01:25:44 PDT
(In reply to comment #7)
> We really ought to fix it soon, though.  Add a FIXME saying that it might
> not do the right thing with unicode characters.

I did some tests and cannot make it faulty, even with non-BMP characters.
That said, it is more consistent to use UTF8Encoding.
Also, this code needs to be changed anyway to remove the no-longer needed vector allocation.
Comment 12 youenn fablet 2016-10-06 03:58:22 PDT
> > > This string exists in many places in WebCore, all of them so far without the charset.  There should be a common place for this const char[] definition somewhere.
> > 
> > Sounds good, how about adding in a future patch common HTTP header values in
> > Source/WebCore/platform/, like in a new file like network/HTTPHeaderValues.*.
> Sure. Different patch ok.

Filed bug 163002 for that.