Bug 57187 - OPTIONS * failure
OPTIONS * failure
Status: RESOLVED FIXED
Product: Tomcat 8
Classification: Unclassified
Component: Catalina
8.0.x-trunk
PC Linux
: P2 normal (vote)
: ----
Assigned To: Tomcat Developers Mailing List
:
Depends on:
Blocks:
  Show dependency tree
 
Reported: 2014-11-05 08:47 UTC by Remy Maucherat
Modified: 2014-11-10 13:42 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Remy Maucherat 2014-11-05 08:47:25 UTC
OPTIONS * HTTP/1.1 is a valid request, but it fails in the resources mapping. Probably as a result of the mapper/resources changes. This special URL should probably not go that far into the mapping process in the first place.

05-Nov-2014 09:04:41.708 SEVERE [http-nio-8083-exec-3] 
org.apache.coyote.http11.AbstractHttp11Processor.process Error 
processing request
  java.lang.IllegalArgumentException: The resource path [*] is not valid
        at org.apache.catalina.webresources.StandardRoot.validate(StandardRoot.java:250)
        at 
org.apache.catalina.webresources.StandardRoot.getResource(StandardRoot.java:212)
        at 
org.apache.catalina.webresources.StandardRoot.getResource(StandardRoot.java:206)
        at org.apache.catalina.mapper.Mapper.internalMapWrapper(Mapper.java:999)
        at org.apache.catalina.mapper.Mapper.internalMap(Mapper.java:817)
        at org.apache.catalina.mapper.Mapper.map(Mapper.java:685)
        at 
org.apache.catalina.connector.CoyoteAdapter.postParseRequest(CoyoteAdapter.java:872)
        at 
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:532)
        at 
org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1085)
        at 
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:658)
        at 
org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:222)
        at 
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1556)
        at 
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1513)
        at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at 
org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
        at java.lang.Thread.run(Thread.java:745)
Comment 1 Remy Maucherat 2014-11-05 08:53:57 UTC
Additional note: Tomcat 7 returns a response that looks correct:
OPTIONS * HTTP/1.1
Host: localhost

HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Allow: GET, HEAD, POST, PUT, DELETE, OPTIONS
Content-Length: 0
Date: Wed, 05 Nov 2014 08:51:16 GMT
Comment 2 Remy Maucherat 2014-11-05 10:58:33 UTC
Fix in r1636850 for 8.0.16.
Comment 3 Konstantin Kolinko 2014-11-10 10:21:45 UTC
REOPENing, as I think there is still more to it.

With current trunk:

GET * HTTP/1.1
Host: a

Expected: Error 400 or error 404 (depends on what is written is the spec, I have not looked there yet). Tomcat 7 returns 404.

Actual: Error 500 with a stacktrace

 java.lang.IllegalArgumentException: The resource path [*] is not valid
	at org.apache.catalina.webresources.StandardRoot.validate(StandardRoot.java:251)
	at org.apache.catalina.webresources.StandardRoot.getResource(StandardRoot.java:212)
	at org.apache.catalina.webresources.StandardRoot.getResource(StandardRoot.java:206)
	at org.apache.catalina.servlets.DefaultServlet.serveResource(DefaultServlet.java:716)
	at org.apache.catalina.servlets.DefaultServlet.doGet(DefaultServlet.java:411)


GET ? HTTP/1.1
Host: a

GET foo HTTP/1.1
Host: a

Expected=Actual: Error 400, as expected.
Other invalid URLs are rejected early. There is special processing for "*" in CoyoteAdapter.normalize(MB) that allows it to survive.
Comment 4 Remy Maucherat 2014-11-10 11:56:49 UTC
OPTIONS * means an OPTIONS method applied to the whole server, it is used my mod_cluster to ping. This is a valid request, which should be processed by the default servlet as it is now. For any other methods, the 404 looked decent.

Looking at the code, I'm not sure what the best option is, since "*" is really invalid as a file path in the resources, and should continue to be rejected with an exception in validate.
Comment 5 Remy Maucherat 2014-11-10 13:05:03 UTC
Another possibility (looking at the code) is to deal with * in CoyoteAdpater.postParseRequest before mapping, and only OPTIONS would return a non 404 response.
Comment 6 jfclere 2014-11-10 13:08:39 UTC
basically OPTIONS * shouldn't be mapped to anything just answered as it is like the CPING/PONG of AJP.
See http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html
Comment 7 Remy Maucherat 2014-11-10 13:42:14 UTC
r1637839