Bug 137865

Summary: XMLHttpRequest using wrong default content-type, forcing CORS preflight
Product: WebKit Reporter: Chris J. Shull <chrisjshull>
Component: New BugsAssignee: Nobody <webkit-unassigned>
Status: RESOLVED DUPLICATE    
Severity: Normal CC: ap, youennf
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Mac (Intel)   
OS: Other   

Description Chris J. Shull 2014-10-19 12:19:25 PDT
Per http://www.w3.org/TR/XMLHttpRequest2/#the-send-method
When sending a string:
Let mime type be "text/plain;charset=UTF-8".

Now try this with an HTTP proxy/monitor and Safari 8.0:
var xhr = new XMLHttpRequest();
var url = "http://www.corsproxy.com/en.wikipedia.org/wiki/Http?" + Date.now();
xhr.open("POST", url, true);
xhr.send("test");

Observed:
An OPTIONS preflight.
Because the Content-Type in the POST request has been set to application/xml.

Expected:
No OPTIONS preflight.
Content-Type in the POST request to be text/plain;charset=UTF-8.
Comment 1 Chris J. Shull 2014-10-19 12:23:54 PDT
For note, Chrome v38 handles this correctly, as does Forefox v33.
Comment 2 Alexey Proskuryakov 2014-10-20 20:59:11 PDT
I think that "text/plain;charset=UTF-8" would also cause preflight, as the implementation stands now.

*** This bug has been marked as a duplicate of bug 99973 ***
Comment 3 youenn fablet 2014-10-21 01:35:11 PDT
(In reply to comment #2)
> I think that "text/plain;charset=UTF-8" would also cause preflight, as the
> implementation stands now.

The request should already be considered as simple by the latest webkit revision.
I will double check this and report.
Comment 4 Alexey Proskuryakov 2014-10-21 09:50:28 PDT
Yes, looks like I was wrong, it doesn't cause a preflight any more.