[OpenLayers-Commits] r11103 - in sandbox/camptocamp/geobretagne/lib/OpenLayers: . Lang

commits-20090109 at openlayers.org commits-20090109 at openlayers.org
Fri Feb 11 08:19:22 EST 2011


Author: fvanderbiest
Date: 2011-02-11 05:19:22 -0800 (Fri, 11 Feb 2011)
New Revision: 11103

Modified:
   sandbox/camptocamp/geobretagne/lib/OpenLayers/Lang/fr.js
   sandbox/camptocamp/geobretagne/lib/OpenLayers/Request.js
Log:
camptocamp/geobretagne sandbox: OpenLayers.Request backport from trunk + patch A0 from #3055

Modified: sandbox/camptocamp/geobretagne/lib/OpenLayers/Lang/fr.js
===================================================================
--- sandbox/camptocamp/geobretagne/lib/OpenLayers/Lang/fr.js	2011-02-11 09:45:49 UTC (rev 11102)
+++ sandbox/camptocamp/geobretagne/lib/OpenLayers/Lang/fr.js	2011-02-11 13:19:22 UTC (rev 11103)
@@ -75,6 +75,7 @@
 
     'pagePositionFailed': "OpenLayers.Util.pagePosition a échoué: l\'élément d\'id ${elemId} pourrait être mal positionné.",
 
-    'filterEvaluateNotImplemented': "évaluer n\'a pas encore été implémenté pour ce type de filtre."
+    'filterEvaluateNotImplemented': "évaluer n\'a pas encore été implémenté pour ce type de filtre.",
 
+    'proxyNeeded': "Vous avez très probablement besoin de renseigner OpenLayers.ProxyHost pour accéder à ${url}. Voir http://trac.osgeo.org/openlayers/wiki/FrequentlyAskedQuestions#ProxyHost"
 });

Modified: sandbox/camptocamp/geobretagne/lib/OpenLayers/Request.js
===================================================================
--- sandbox/camptocamp/geobretagne/lib/OpenLayers/Request.js	2011-02-11 09:45:49 UTC (rev 11102)
+++ sandbox/camptocamp/geobretagne/lib/OpenLayers/Request.js	2011-02-11 13:19:22 UTC (rev 11103)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2010 by OpenLayers Contributors (see authors.txt for 
+/* Copyright (c) 2006-2011 by OpenLayers Contributors (see authors.txt for 
  * full list of contributors). Published under the Clear BSD license.  
  * See http://svn.openlayers.org/trunk/openlayers/license.txt for the
  * full text of the license. */
@@ -36,6 +36,11 @@
     },
     
     /**
+     * Constant: URL_SPLIT_REGEX
+     */
+    URL_SPLIT_REGEX: /([^:]*:)\/\/([^:]*:?[^@]*@)?([^:\/\?]*):?([^\/\?]*)/,
+    
+    /**
      * APIProperty: events
      * {<OpenLayers.Events>} An events object that handles all 
      *     events on the {<OpenLayers.Request>} object.
@@ -120,19 +125,30 @@
 
         // create request, open, and set headers
         var request = new OpenLayers.Request.XMLHttpRequest();
-        var url = config.url;
-        if(config.params) {
-            var paramString = OpenLayers.Util.getParameterString(config.params);
-            if(paramString.length > 0) {
-                var separator = (url.indexOf('?') > -1) ? '&' : '?';
-                url += separator + paramString;
+        var url = OpenLayers.Util.urlAppend(config.url, 
+            OpenLayers.Util.getParameterString(config.params || {}));
+        var sameOrigin = !(url.indexOf("http") == 0);
+        var urlParts = !sameOrigin && url.match(this.URL_SPLIT_REGEX);
+        if (urlParts) {
+            var location = window.location;
+            sameOrigin =
+                urlParts[1] == location.protocol &&
+                urlParts[3] == location.hostname;
+            var uPort = urlParts[4], lPort = location.port;
+            if (uPort != 80 && uPort != "" || lPort != "80" && lPort != "") {
+                sameOrigin = sameOrigin && uPort == lPort;
             }
         }
-        if(config.proxy && (url.indexOf("http") == 0)) {
-            if(typeof config.proxy == "function") {
-                url = config.proxy(url);
+        if (!sameOrigin) {
+            if (config.proxy) {
+                if (typeof config.proxy == "function") {
+                    url = config.proxy(url);
+                } else {
+                    url = config.proxy + encodeURIComponent(url);
+                }
             } else {
-                url = config.proxy + encodeURIComponent(url);
+                OpenLayers.Console.warn(
+                    OpenLayers.i18n("proxyNeeded"), {url: url});
             }
         }
         request.open(
@@ -169,7 +185,7 @@
             request.send(config.data);
         } else {
             window.setTimeout(function(){
-                if (request._aborted !== true) {
+                if (request.readyState !== 0) { // W3C: 0-UNSENT
                     request.send(config.data);
                 }
             }, 0);



More information about the Commits mailing list