Skip to content

Commit

Permalink
Proxy / Make distinction between methods.
Browse files Browse the repository at this point in the history
Some servers provides CORS header for some method eg. GET and not for other eg. HEAD.
In such case, if a failure occurs on a HEAD request, then the proxy is activated for that domain but is not needed for GET request. If user is anonymous, then proxy forbid access to the domain (if the domain is not in the link analysis table with default configuration) and simple action like `GetCapabilities` will fail.

Add the method to the domain as key to know if the proxy has to be used or not.

Can be tested with https://haleconnect.com/ows/services/org.789.b36c0053-db6b-4fe7-9402-4e5d8ac35e06_wms
  • Loading branch information
fxprunayre committed May 14, 2024
1 parent 5535b5a commit 3f5ee93
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -895,7 +895,7 @@
};

var loadFunction = function (imageTile, src) {
$http.head(src, { nointercept: true }).then(
$http.head(src).then(
function (r) {
imageTile.getImage().src = src;
},
Expand Down Expand Up @@ -1660,7 +1660,7 @@
var _url = url.split("/");
_url = _url[0] + "/" + _url[1] + "/" + _url[2] + "/";
if (
$.inArray(_url, gnGlobalSettings.requireProxy) >= 0 &&
$.inArray(_url + "#GET", gnGlobalSettings.requireProxy) >= 0 &&
url.indexOf(gnGlobalSettings.proxyUrl) != 0
) {
capL.useProxy = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,15 @@
if (mapservice !== null) {
if (mapservice.useProxy) {
// If we need to use the proxy then add it to requireProxy list.
if ($.inArray(config.url, gnGlobalSettings.requireProxy) === -1) {
if (
$.inArray(
config.url + "#" + config.method,
gnGlobalSettings.requireProxy
) === -1
) {
var url = config.url.split("/");
url = url[0] + "/" + url[1] + "/" + url[2] + "/";
gnGlobalSettings.requireProxy.push(url);
gnGlobalSettings.requireProxy.push(url + "#" + config.method);
}
} else {
// If we are not using a proxy then add the headers.
Expand Down Expand Up @@ -113,7 +118,10 @@
var url = config.url.split("/");
url = url[0] + "/" + url[1] + "/" + url[2] + "/";

if ($.inArray(url, gnGlobalSettings.requireProxy) !== -1) {
if (
$.inArray(url + "#" + config.method, gnGlobalSettings.requireProxy) !==
-1
) {
// require proxy
config.url = gnGlobalSettings.proxyUrl + encodeURIComponent(config.url);
}
Expand Down Expand Up @@ -156,8 +164,13 @@
var url = config.url.split("/");
url = url[0] + "/" + url[1] + "/" + url[2] + "/";

if ($.inArray(url, gnGlobalSettings.requireProxy) === -1) {
gnGlobalSettings.requireProxy.push(url);
if (
$.inArray(
url + "#" + config.method,
gnGlobalSettings.requireProxy
) === -1
) {
gnGlobalSettings.requireProxy.push(url + "#" + config.method);
}

$injector.invoke([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
var url = $scope.url.split("/");
getCapLayer.useProxy = false;
url = url[0] + "/" + url[1] + "/" + url[2] + "/";
if ($.inArray(url, gnGlobalSettings.requireProxy) >= 0) {
if ($.inArray(url + "#GET", gnGlobalSettings.requireProxy) >= 0) {
getCapLayer.useProxy = true;
}
if ($scope.format == "wms") {
Expand Down

0 comments on commit 3f5ee93

Please sign in to comment.