Bug 211999

Summary: XMLHTTPRequest.send should not send Content-Type headers when Blob has no type
Product: WebKit Reporter: Rob Buis <rbuis>
Component: New BugsAssignee: Rob Buis <rbuis>
Status: RESOLVED FIXED    
Severity: Normal CC: achristensen, Russiandevil, webkit-bug-importer, youennf
Priority: P2 Keywords: InRadar
Version: Safari Technology Preview   
Hardware: Unspecified   
OS: Unspecified   
See Also: https://bugs.webkit.org/show_bug.cgi?id=213059
Bug Depends on:    
Bug Blocks: 213690    
Attachments:
Description Flags
Patch
none
Patch
none
Patch
none
Patch
none
Patch none

Description Rob Buis 2020-05-17 12:25:28 PDT
XMLHTTPRequest.send should not send Content-Type headers when Blob has no type [1, 2].
This behavior overrides the behavior of the File API spec [3].

[1] https://xhr.spec.whatwg.org/#dom-xmlhttprequest-send
[2] https://fetch.spec.whatwg.org/#concept-bodyinit-extract
[3] http://dev.w3.org/2006/webapi/FileAPI/#dfn-type
Comment 1 Rob Buis 2020-05-17 12:28:37 PDT
Created attachment 399599 [details]
Patch
Comment 2 Rob Buis 2020-05-17 13:32:08 PDT
Created attachment 399604 [details]
Patch
Comment 3 Rob Buis 2020-05-18 00:04:48 PDT
Created attachment 399625 [details]
Patch
Comment 4 Rob Buis 2020-06-08 07:49:10 PDT
Created attachment 401335 [details]
Patch
Comment 5 Rob Buis 2020-06-08 09:17:37 PDT
Created attachment 401344 [details]
Patch
Comment 6 EWS 2020-06-08 23:44:52 PDT
Committed r262776: <https://trac.webkit.org/changeset/262776>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 401344 [details].
Comment 7 Radar WebKit Bug Importer 2020-06-08 23:45:20 PDT
<rdar://problem/64152152>
Comment 8 youenn fablet 2020-06-09 02:04:23 PDT
Comment on attachment 401344 [details]
Patch

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

> Source/WebCore/platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.mm:125
> +        // CFNetwork will add "application/x-www-form-urlencoded" content-type for POST, even if no Content-Type was specified, remove it in that case.

If that is true, CFNetwork should probably fix that issue as well.
Is there a test that is exhibiting that issue?
Comment 9 youenn fablet 2020-06-09 02:04:25 PDT
Comment on attachment 401344 [details]
Patch

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

> Source/WebCore/platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.mm:125
> +        // CFNetwork will add "application/x-www-form-urlencoded" content-type for POST, even if no Content-Type was specified, remove it in that case.

If that is true, CFNetwork should probably fix that issue as well.
Is there a test that is exhibiting that issue?
Comment 10 youenn fablet 2020-06-09 02:04:53 PDT
*** Bug 159210 has been marked as a duplicate of this bug. ***
Comment 11 Rob Buis 2020-06-09 02:30:18 PDT
Comment on attachment 401344 [details]
Patch

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

>>> Source/WebCore/platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.mm:125
>>> +        // CFNetwork will add "application/x-www-form-urlencoded" content-type for POST, even if no Content-Type was specified, remove it in that case.
>> 
>> If that is true, CFNetwork should probably fix that issue as well.
>> Is there a test that is exhibiting that issue?
> 
> If that is true, CFNetwork should probably fix that issue as well.
> Is there a test that is exhibiting that issue?

To be clear, this remark is only true for WK1, WK2 is fine. Maybe it is the difference of using NSURLConnection for WK1 versus NSURLSession?

The test is imported/w3c/web-platform-tests/xhr/send-blob-with-no-mime-type.html, or did I misunderstand your question?
Comment 12 Alex Christensen 2020-06-09 08:20:29 PDT
NSURLConnection bugs have low likelihood of being fixed.  This fix is fine.
Comment 13 Alex Christensen 2020-07-18 21:59:59 PDT
This broke an app.  I fix the app in https://bugs.webkit.org/show_bug.cgi?id=214528