check if using a proxy is required, and if so, issue a warning if none is configured. p=fvanderbiest,me r=me (closes #3015)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@11038 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -122,6 +122,9 @@ OpenLayers.Lang.en = {
|
||||
// console message
|
||||
'filterEvaluateNotImplemented': "evaluate is not implemented for this filter type.",
|
||||
|
||||
'proxyNeeded': "You probably need to set OpenLayers.ProxyHost to access ${url}."+
|
||||
"See http://trac.osgeo.org/openlayers/wiki/FrequentlyAskedQuestions#ProxyHost",
|
||||
|
||||
// **** end ****
|
||||
'end': ''
|
||||
|
||||
|
||||
@@ -75,6 +75,7 @@ OpenLayers.Lang["fr"] = OpenLayers.Util.applyDefaults({
|
||||
|
||||
'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"
|
||||
});
|
||||
|
||||
@@ -35,6 +35,11 @@ OpenLayers.Request = {
|
||||
scope: null
|
||||
},
|
||||
|
||||
/**
|
||||
* Constant: URL_SPLIT_REGEX
|
||||
*/
|
||||
URL_SPLIT_REGEX: /([^:]*:)\/\/([^:]*:?[^@]*@)?([^:\/\?]*):?([^\/\?]*)/,
|
||||
|
||||
/**
|
||||
* APIProperty: events
|
||||
* {<OpenLayers.Events>} An events object that handles all
|
||||
@@ -128,11 +133,28 @@ OpenLayers.Request = {
|
||||
url += separator + paramString;
|
||||
}
|
||||
}
|
||||
if(config.proxy && (url.indexOf("http") == 0)) {
|
||||
if(typeof config.proxy == "function") {
|
||||
url = config.proxy(url);
|
||||
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 (!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(
|
||||
|
||||
Reference in New Issue
Block a user