Bug 1300642 - Set default UA request header before on-opening-request notification to allow its override. r=mcmanus
authorHonza Bambas <honzab.moz@firemni.cz>
Wed, 16 Nov 2016 08:57:00 -0500
changeset 323182 5702ad092400bedabfc93185670b14de67c57917
parent 323181 60bb7c0191272b26978d3420c2c2d169e219dc41
child 323183 7a79f153b1eb227b06b6b032f1db08da167967ff
push id30971
push usercbook@mozilla.com
push dateFri, 18 Nov 2016 15:51:34 +0000
treeherdermozilla-central@a103e1713a2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmcmanus
bugs1300642
milestone53.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1300642 - Set default UA request header before on-opening-request notification to allow its override. r=mcmanus
netwerk/protocol/http/nsHttpChannel.cpp
--- a/netwerk/protocol/http/nsHttpChannel.cpp
+++ b/netwerk/protocol/http/nsHttpChannel.cpp
@@ -5683,30 +5683,32 @@ nsHttpChannel::AsyncOpen(nsIStreamListen
     // Remember the cookie header that was set, if any
     nsAutoCString cookieHeader;
     if (NS_SUCCEEDED(mRequestHead.GetHeader(nsHttp::Cookie, cookieHeader))) {
         mUserSetCookieHeader = cookieHeader;
     }
 
     AddCookiesToRequest();
 
+    // Set user agent override, do so before OnOpeningRequest notification
+    // since we want to allow consumers of that notification change or remove
+    // the User-Agent request header.
+    HttpBaseChannel::SetDocshellUserAgentOverride();
+
     // After we notify any observers (on-opening-request, loadGroup, etc) we
     // must return NS_OK and return any errors asynchronously via
     // OnStart/OnStopRequest.  Observers may add a reference to the channel
     // and expect to get OnStopRequest so they know when to drop the reference,
     // etc.
 
     // notify "http-on-opening-request" observers, but not if this is a redirect
     if (!(mLoadFlags & LOAD_REPLACE)) {
         gHttpHandler->OnOpeningRequest(this);
     }
 
-    // Set user agent override
-    HttpBaseChannel::SetDocshellUserAgentOverride();
-
     mIsPending = true;
     mWasOpened = true;
 
     mListener = listener;
     mListenerContext = context;
 
     if (mLoadGroup)
         mLoadGroup->AddRequest(this, nullptr);