Bug 1381718 : Dump request when receiving 400 error r=hchang
authorThomas Nguyen <tnguyen@mozilla.com>
Tue, 25 Jul 2017 14:43:11 +0800
changeset 419774 965f1bcd6d74c9daa329034a33d096a90cecc651
parent 419773 382ac74f97a20dd13918d7e0891766bfd4efa001
child 419775 08a4bab2247ad15c8ba3da16b727b28996278117
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewershchang
bugs1381718
milestone56.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 1381718 : Dump request when receiving 400 error r=hchang MozReview-Commit-ID: 1ZFOIRTryiV
toolkit/components/url-classifier/nsUrlClassifierHashCompleter.js
toolkit/components/url-classifier/nsUrlClassifierStreamUpdater.cpp
--- a/toolkit/components/url-classifier/nsUrlClassifierHashCompleter.js
+++ b/toolkit/components/url-classifier/nsUrlClassifierHashCompleter.js
@@ -423,26 +423,26 @@ HashCompleterRequest.prototype = {
     }
   },
 
   // Creates an nsIChannel for the request and fills the body.
   openChannel: function HCR_openChannel() {
     let loadFlags = Ci.nsIChannel.INHIBIT_CACHING |
                     Ci.nsIChannel.LOAD_BYPASS_CACHE;
 
-    let actualGethashUrl = this.gethashUrl;
+    this.actualGethashUrl = this.gethashUrl;
     if (this.isV4) {
       // As per spec, we add the request payload to the gethash url.
-      actualGethashUrl += "&$req=" + this.buildRequestV4();
+      this.actualGethashUrl += "&$req=" + this.buildRequestV4();
     }
 
-    log("actualGethashUrl: " + actualGethashUrl);
+    log("actualGethashUrl: " + this.actualGethashUrl);
 
     let channel = NetUtil.newChannel({
-      uri: actualGethashUrl,
+      uri: this.actualGethashUrl,
       loadUsingSystemPrincipal: true
     });
     channel.loadFlags = loadFlags;
     channel.loadInfo.originAttributes = {
       // The firstPartyDomain value should sync with NECKO_SAFEBROWSING_FIRST_PARTY_DOMAIN
       // defined in nsNetUtil.h.
       firstPartyDomain: "safebrowsing.86868755-6b82-4842-b301-72671a0db32e.mozilla"
     };
@@ -760,16 +760,21 @@ HashCompleterRequest.prototype = {
         aStatusCode = Cr.NS_ERROR_ABORT;
       }
     }
     let success = Components.isSuccessCode(aStatusCode);
     log('Received a ' + httpStatus + ' status code from the gethash server (success=' + success + ').');
 
     Services.telemetry.getKeyedHistogramById("URLCLASSIFIER_COMPLETE_REMOTE_STATUS2").
       add(this.telemetryProvider, httpStatusToBucket(httpStatus));
+    if (httpStatus == 400) {
+      dump("Safe Browsing server returned a 400 during completion: request= " +
+           this.actualGethashUrl + "\n");
+    }
+
     Services.telemetry.getKeyedHistogramById("URLCLASSIFIER_COMPLETE_TIMEOUT2").
       add(this.telemetryProvider, 0);
 
     // Notify the RequestBackoff once a response is received.
     this._completer.finishRequest(this.gethashUrl, httpStatus);
 
     if (success) {
       try {
--- a/toolkit/components/url-classifier/nsUrlClassifierStreamUpdater.cpp
+++ b/toolkit/components/url-classifier/nsUrlClassifierStreamUpdater.cpp
@@ -769,16 +769,27 @@ nsUrlClassifierStreamUpdater::OnStartReq
       rv = httpChannel->GetRequestSucceeded(&succeeded);
       NS_ENSURE_SUCCESS(rv, rv);
 
       uint32_t requestStatus;
       rv = httpChannel->GetResponseStatus(&requestStatus);
       NS_ENSURE_SUCCESS(rv, rv);
       mozilla::Telemetry::Accumulate(mozilla::Telemetry::URLCLASSIFIER_UPDATE_REMOTE_STATUS2,
                                      mTelemetryProvider, HTTPStatusToBucket(requestStatus));
+      if (requestStatus == 400) {
+        nsCOMPtr<nsIURI> uri;
+        nsAutoCString spec;
+        rv = httpChannel->GetURI(getter_AddRefs(uri));
+        if (NS_SUCCEEDED(rv) && uri) {
+          uri->GetAsciiSpec(spec);
+        }
+        printf_stderr("Safe Browsing server returned a 400 during update: request = %s \n",
+                      spec.get());
+      }
+
       LOG(("nsUrlClassifierStreamUpdater::OnStartRequest %s (%d)", succeeded ?
            "succeeded" : "failed", requestStatus));
       if (!succeeded) {
         // 404 or other error, pass error status back
         strStatus.AppendInt(requestStatus);
         downloadError = true;
       }
     }