Backout of bug 1207233 due to web-compat concerns
authorMichael Layzell <michael@thelayzells.com>
Tue, 13 Oct 2015 23:50:33 -0400
changeset 267763 35346de03a7388bc2c411c722ed3bff67c13c54e
parent 267762 efb3eb13c8bfa712edfb5548f3d1a30b70198924
child 267764 ab276d264008c60bfd20dcc5c13a4e3c48db41dd
push idunknown
push userunknown
push dateunknown
bugs1207233
milestone44.0a1
Backout of bug 1207233 due to web-compat concerns
dom/base/nsXMLHttpRequest.cpp
netwerk/protocol/http/HttpBaseChannel.cpp
testing/web-platform/meta/XMLHttpRequest/setrequestheader-content-type.htm.ini
--- a/dom/base/nsXMLHttpRequest.cpp
+++ b/dom/base/nsXMLHttpRequest.cpp
@@ -2699,17 +2699,18 @@ nsXMLHttpRequest::Send(nsIVariant* aVari
       net::InScriptableRange(size_u64) ? static_cast<int64_t>(size_u64) : -1;
 
     if (postDataStream) {
       // If no content type header was set by the client, we set it to
       // application/xml.
       nsAutoCString contentType;
       if (NS_FAILED(httpChannel->
                       GetRequestHeader(NS_LITERAL_CSTRING("Content-Type"),
-                                       contentType))) {
+                                       contentType)) ||
+          contentType.IsEmpty()) {
         contentType = defaultContentType;
 
         if (!charset.IsEmpty()) {
           // If we are providing the default content type, then we also need to
           // provide a charset declaration.
           contentType.Append(NS_LITERAL_CSTRING(";charset="));
           contentType.Append(charset);
         }
--- a/netwerk/protocol/http/HttpBaseChannel.cpp
+++ b/netwerk/protocol/http/HttpBaseChannel.cpp
@@ -717,23 +717,18 @@ HttpBaseChannel::ExplicitSetUploadStream
   NS_ENSURE_SUCCESS(rv, rv);
 
   if (!aStreamHasHeaders) {
     // SetRequestHeader propagates headers to chrome if HttpChannelChild
     nsAutoCString contentLengthStr;
     contentLengthStr.AppendInt(aContentLength);
     SetRequestHeader(NS_LITERAL_CSTRING("Content-Length"), contentLengthStr,
                      false);
-
-    if (aContentType.IsEmpty()) {
-      SetEmptyRequestHeader(NS_LITERAL_CSTRING("Content-Type"));
-    } else {
-      SetRequestHeader(NS_LITERAL_CSTRING("Content-Type"), aContentType,
-                       false);
-    }
+    SetRequestHeader(NS_LITERAL_CSTRING("Content-Type"), aContentType,
+                     false);
   }
 
   mUploadStreamHasHeaders = aStreamHasHeaders;
   mUploadStream = aStream;
   return NS_OK;
 }
 
 NS_IMETHODIMP
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/meta/XMLHttpRequest/setrequestheader-content-type.htm.ini
@@ -0,0 +1,5 @@
+[setrequestheader-content-type.htm]
+  type: testharness
+  [XMLHttpRequest: setRequestHeader() - Content-Type header ()]
+    expected: FAIL
+