Bug 1111834 - CORS request after preflight should not follow 30x redirect. r=sicking, a=lmandel
authorChristoph Kerschbaumer <mozilla@christophkerschbaumer.com>
Thu, 19 Feb 2015 13:43:40 -0800
changeset 250313 46aa1d78bd2e
parent 250312 bcd0c508c109
child 250314 173e1bbcd0b6
push id4543
push userryanvm@gmail.com
push date2015-03-09 19:31 +0000
treeherdermozilla-beta@46aa1d78bd2e [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::GetSameOriginChecker();
+    channel->SetNotificationCallbacks(soc);
+
     nsCOMPtr<nsIChannel> preflightChannel;
     nsTArray<nsCString> unsafeHeaders;
     unsafeHeaders.AppendElement(NS_LITERAL_CSTRING("Content-Type"));
     rv = NS_StartCORSPreflight(channel,
                                cors,
                                principal,
                                true,
                                unsafeHeaders,