Bug 1353082 - don't prefetch is there's a query string r=mcmanus
authorNicholas Hurley <hurley@mozilla.com>
Mon, 27 Mar 2017 14:56:05 -0700
changeset 556177 63005e2a60863c2fa9f3fe8d31656edca3d1296d
parent 556176 9687165d5721ed8b80c767056c90575857b72d6b
child 556178 b68c5d48eebb6bddc7513b71bda2cf976145c526
push id52480
push userbmo:standard8@mozilla.com
push dateWed, 05 Apr 2017 14:31:04 +0000
reviewersmcmanus
bugs1353082
milestone55.0a1
Bug 1353082 - don't prefetch is there's a query string r=mcmanus
netwerk/base/Predictor.cpp
--- a/netwerk/base/Predictor.cpp
+++ b/netwerk/base/Predictor.cpp
@@ -2636,32 +2636,38 @@ Predictor::CacheabilityAction::OnCacheEn
     PREDICTOR_LOG(("    VisitMetaData returned %" PRIx32, static_cast<uint32_t>(rv)));
     return NS_OK;
   }
 
   nsTArray<nsCString> keysToCheck, valuesToCheck;
   keysToCheck.SwapElements(mKeysToCheck);
   valuesToCheck.SwapElements(mValuesToCheck);
 
+  bool hasQueryString = false;
+  nsAutoCString query;
+  if (NS_SUCCEEDED(mTargetURI->GetQuery(query)) && !query.IsEmpty()) {
+    hasQueryString = true;
+  }
+
   MOZ_ASSERT(keysToCheck.Length() == valuesToCheck.Length());
   for (size_t i = 0; i < keysToCheck.Length(); ++i) {
     const char *key = keysToCheck[i].BeginReading();
     const char *value = valuesToCheck[i].BeginReading();
     nsCOMPtr<nsIURI> uri;
     uint32_t hitCount, lastHit, flags;
 
     if (!mPredictor->ParseMetaDataEntry(key, value, getter_AddRefs(uri),
                                         hitCount, lastHit, flags)) {
       PREDICTOR_LOG(("    failed to parse key=%s value=%s", key, value));
       continue;
     }
 
     bool eq = false;
     if (NS_SUCCEEDED(uri->Equals(mTargetURI, &eq)) && eq) {
-      if (mHttpStatus == 200 && mMethod.EqualsLiteral("GET")) {
+      if (mHttpStatus == 200 && mMethod.EqualsLiteral("GET") && !hasQueryString) {
         PREDICTOR_LOG(("    marking %s cacheable", key));
         flags |= FLAG_PREFETCHABLE;
       } else {
         PREDICTOR_LOG(("    marking %s uncacheable", key));
         flags &= ~FLAG_PREFETCHABLE;
       }
       nsCString newValue;
       MakeMetadataEntry(hitCount, lastHit, flags, newValue);