Bug 1111834 - CORS request after preflight should not follow 30x redirect. r=sicking, a=lmandel
☠☠ backed out by bcd0c508c109 ☠ ☠
authorChristoph Kerschbaumer <mozilla@christophkerschbaumer.com>
Thu, 19 Feb 2015 13:43:40 -0800
changeset 250303 24f079da6625
parent 250302 513cff18abaa
child 250304 8746f7ba56c9
push id4541
push userryanvm@gmail.com
push date2015-03-09 19:01 +0000
treeherdermozilla-beta@58b004077c10 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssicking, lmandel
bugs1111834
milestone37.0
Bug 1111834 - CORS request after preflight should not follow 30x redirect. r=sicking, a=lmandel
dom/base/Navigator.cpp
--- a/dom/base/Navigator.cpp
+++ b/dom/base/Navigator.cpp
@@ -1212,16 +1212,22 @@ Navigator::SendBeacon(const nsAString& a
   bool crossOrigin = NS_FAILED(rv);
   nsAutoCString contentType, parsedCharset;
   rv = NS_ParseContentType(mimeType, contentType, parsedCharset);
   if (crossOrigin &&
       contentType.Length() > 0 &&
       !contentType.Equals(APPLICATION_WWW_FORM_URLENCODED) &&
       !contentType.Equals(MULTIPART_FORM_DATA) &&
       !contentType.Equals(TEXT_PLAIN)) {
+
+    // we need to set the sameOriginChecker as a notificationCallback
+    // so we can tell the channel not to follow redirects
+    nsCOMPtr<nsIInterfaceRequestor> soc = nsContentUtils::SameOriginChecker();
+    channel->SetNotificationCallbacks(soc);
+
     nsCOMPtr<nsIChannel> preflightChannel;
     nsTArray<nsCString> unsafeHeaders;
     unsafeHeaders.AppendElement(NS_LITERAL_CSTRING("Content-Type"));
     rv = NS_StartCORSPreflight(channel,
                                cors,
                                principal,
                                true,
                                unsafeHeaders,