Bug 713991 - Geolocation fails when used with large number of access points. r=gmealer a=akeybl
authorDoug Turner <dougt@dougt.org>
Tue, 03 Jan 2012 20:13:34 -0800
changeset 84841 3b8917046a7889bf4483d302b5f257cf69d4a43a
parent 84840 ea508b336fed146addd2d2813c5a92fd53ae1d2c
child 84842 1d0e777d59e155325e9521f679fd751f199ad196
push id519
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 00:38:35 +0000
treeherdermozilla-beta@788ea1ef610b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgmealer, akeybl
bugs713991
milestone11.0a2
Bug 713991 - Geolocation fails when used with large number of access points. r=gmealer a=akeybl
dom/system/NetworkGeolocationProvider.js
--- a/dom/system/NetworkGeolocationProvider.js
+++ b/dom/system/NetworkGeolocationProvider.js
@@ -213,27 +213,29 @@ WifiGeoPositionProvider.prototype = {
       // make sure that the ssid doesn't contain any | chars.
       ap.ssid = ap.ssid.replace("|", "\\|");
       // gls service parses the | as fields
       return "&wifi=mac:"+ap.mac+"|ssid:"+ap.ssid+"|ss:"+ap.signal;
     };
 
     if (accessPoints) {
         providerUrl = providerUrl + accessPoints.sort(sort).map(encode).join("");
-        // max length is 2k.  make sure we are under that
-        let x = providerUrl.length - 2000;
-        if (x >= 0) {
-            // we need to trim
-            let doomed = providerUrl.lastIndexOf("&", 2000);
-            LOG("Doomed:"+doomed);
-            providerUrl = providerUrl.substring(0, doomed);
-        }
     }
 
     providerUrl = encodeURI(providerUrl);
+
+    // max length is 2k.  make sure we are under that
+    let x = providerUrl.length - 2000;
+    if (x >= 0) {
+	// we need to trim
+	let doomed = providerUrl.lastIndexOf("&", 2000);
+	LOG("Doomed:"+doomed);
+	providerUrl = providerUrl.substring(0, doomed);
+    }
+    
     LOG("************************************* Sending request:\n" + providerUrl + "\n");
 
     // send our request to a wifi geolocation network provider:
     let xhr = Components.classes["@mozilla.org/xmlextras/xmlhttprequest;1"]
                         .createInstance(Ci.nsIXMLHttpRequest);
 
     // This is a background load
     xhr.mozBackgroundRequest = true;