Skip to content

Commit 0dff195

Browse files
geonetworkbuildjosegar74fxprunayre
authored
[Backport 4.2.x] WMS GetMap HEAD request error response - check response status defined (geonetwork#8076)
* WMS GetMap HEAD request error response - check response status defined Follow up of geonetwork#7000 * WMS GetMap HEAD request error response - Don't use CORS interceptor. If the map service doesn't support HEAD (or CORS for HEAD requests), all other requests to the server go through the http proxy, even if the server supports CORS for these requests * Proxy / Make distinction between methods. (#101) 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 --------- Co-authored-by: Jose García <[email protected]> Co-authored-by: François Prunayre <[email protected]>
1 parent 29d51ca commit 0dff195

File tree

3 files changed

+20
-7
lines changed

3 files changed

+20
-7
lines changed

web-ui/src/main/resources/catalog/components/common/map/mapService.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1660,7 +1660,7 @@
16601660
var _url = url.split("/");
16611661
_url = _url[0] + "/" + _url[1] + "/" + _url[2] + "/";
16621662
if (
1663-
$.inArray(_url, gnGlobalSettings.requireProxy) >= 0 &&
1663+
$.inArray(_url + "#GET", gnGlobalSettings.requireProxy) >= 0 &&
16641664
url.indexOf(gnGlobalSettings.proxyUrl) != 0
16651665
) {
16661666
capL.useProxy = true;

web-ui/src/main/resources/catalog/components/utility/CORSInterceptor.js

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,15 @@
8181
if (mapservice !== null) {
8282
if (mapservice.useProxy) {
8383
// If we need to use the proxy then add it to requireProxy list.
84-
if ($.inArray(config.url, gnGlobalSettings.requireProxy) === -1) {
84+
if (
85+
$.inArray(
86+
config.url + "#" + config.method,
87+
gnGlobalSettings.requireProxy
88+
) === -1
89+
) {
8590
var url = config.url.split("/");
8691
url = url[0] + "/" + url[1] + "/" + url[2] + "/";
87-
gnGlobalSettings.requireProxy.push(url);
92+
gnGlobalSettings.requireProxy.push(url + "#" + config.method);
8893
}
8994
} else {
9095
// If we are not using a proxy then add the headers.
@@ -113,7 +118,10 @@
113118
var url = config.url.split("/");
114119
url = url[0] + "/" + url[1] + "/" + url[2] + "/";
115120

116-
if ($.inArray(url, gnGlobalSettings.requireProxy) !== -1) {
121+
if (
122+
$.inArray(url + "#" + config.method, gnGlobalSettings.requireProxy) !==
123+
-1
124+
) {
117125
// require proxy
118126
config.url = gnGlobalSettings.proxyUrl + encodeURIComponent(config.url);
119127
}
@@ -156,8 +164,13 @@
156164
var url = config.url.split("/");
157165
url = url[0] + "/" + url[1] + "/" + url[2] + "/";
158166

159-
if ($.inArray(url, gnGlobalSettings.requireProxy) === -1) {
160-
gnGlobalSettings.requireProxy.push(url);
167+
if (
168+
$.inArray(
169+
url + "#" + config.method,
170+
gnGlobalSettings.requireProxy
171+
) === -1
172+
) {
173+
gnGlobalSettings.requireProxy.push(url + "#" + config.method);
161174
}
162175

163176
$injector.invoke([

web-ui/src/main/resources/catalog/components/viewer/wmsimport/WmsImportDirective.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
var url = $scope.url.split("/");
8888
getCapLayer.useProxy = false;
8989
url = url[0] + "/" + url[1] + "/" + url[2] + "/";
90-
if ($.inArray(url, gnGlobalSettings.requireProxy) >= 0) {
90+
if ($.inArray(url + "#GET", gnGlobalSettings.requireProxy) >= 0) {
9191
getCapLayer.useProxy = true;
9292
}
9393
if ($scope.format == "wms") {

0 commit comments

Comments
 (0)