-
-
Notifications
You must be signed in to change notification settings - Fork 96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HTTP OPTIONS Request to getcababilities throws a 405 error #268
Comments
Might be worth taking this to the mapserver-users or mapserver-dev list - more eyes... |
I don't think that the response is so important. Important seems to bee an response header with HTTP Code 200 ( not 405) and maybe the OPTIONS header curl -X OPTIONS "https://path.to.server/mapserver/mymap?service=WMS&request=GetCapabilities" -i HTTP/1.1 200 OK This script should be referenced with a METHOD of GET or METHOD of POST. |
I believe that the supported http methods are configured with your web server. I have found documents about how to disable OPTIONS method that is considered to be some kind of security issue. I used the recipe from https://support.cpanel.net/hc/en-us/articles/360057430513-How-To-disable-http-OPTIONS-method-in-Apache- and made a trial with MS4W. I edited the Apache httpd.conf like this
After restart curl -X OPTIONS leads into this:
So I could change Mapserver to behave about in the same way than MapCache does for you. From all that I read from the web I got a feeling that web servers do not need to support OPTIONS and code 405 is probably the best response then https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/405. My conclusions: if you want to support OPTIONS method with the web server on which you are running MapCache, study how to configure that web server. And generally no client should rely on that OPTIONS is supported because usually it is not. I tried with a bunch of sites and 405 was the most common result. Try for example with google.com. |
Thanks for the research @jratike80, I'm going to add this note to the MS4W readme for the next release (ticket: https://ms4w.com/trac/ticket/351). |
I tried to configure Apache to anwser the OPTIONS request to mapache, but until know without success. In addition, there seems to be a useful reason to make an OPTIONS request in the sense of a CORS preflight. |
I think now that configuring http server is not enough. The accepted methods seem to be hardcoded into https://github.com/MapServer/mapcache/blob/447c0c6848fd101c11e6d54e451037e571117ef1/apache/mod_mapcache.c
Your description of the problem is that Chrome cannot read GetCapabilities from MapCache because it automatically adds the OPTIONS header and it requires that the server supports OPTIONS method. If server does not allow OPTIONS and sends the 405 response, that is right according to the http standard, then Crome can not read GetCapabilities. What is your Chrome version? I have version 94.0.4606.71 and I made the following test:
It works, but I was reading that Chrome 79 has some changes on this area https://httptoolkit.tech/blog/chrome-79-doesnt-show-cors-preflight/ so perhaps my Chrome is just too old for showing the issue. |
I think the OPTIONS request is quite important. With an OPTIONS request the client asks the server which requests are allowed. Which methods are allowed and if the client should even attempt to send the full request. It's also vitally important for CORS requests. Most of the browser should send a We had a similar problem like OP. Our MapCache runs in a docker container (https://github.com/camptocamp/docker-mapcache) and we could not get the requests through to the server. We extended the Dockerfile with:
This enables the apache headers module and copies the apache CORS configuration into the container. This is how the
I'm not a not sure about all the details of HTTP request methods but, I know that without a valid OPTIONS response most browser refuse to make the full request. Even though they are not manatory. |
Google Chrome calls the GETCAPABILITIES request as HTTP OPTIONS request in our Geoportal-application.
mapchache delivers a 405 Issue to this request
Example:
curl -X OPTIONS https://path.to.server/mapcache/wmts?SERVICE=WMTS&REQUEST=getcapabilities -i
Response from mapache:
_
<title>405 Method Not Allowed</title>Method Not Allowed
The requested method OPTIONS is not allowed for this URL.
_I don't know why Google Chrome uses the HTTP OPTIONS in header, but it does.
Our applications stops with error 405.
Other browsers seem to work without any problems.
Is there a configuration option to configure OPTIONS requests?
Regards
Peter
The text was updated successfully, but these errors were encountered: