Search code examples
httptomcat6neonhttp-status-code-100

How to check if PUT can be performed before sending request body?


Note: we are using lib_neon on client side and Tomcat and servlet api on server side.

The problem is following: when client wants to put some content, it performs a PUT request with an "Expect: 100-continue" header, Tomcat handles it by simply returning status 100 Continue and after that client starts to send the remaining part of request, and it gets processed by our custom Filters and often it doesn't pass (for instance user is not authorized, or tries to put too large file, exceeding users limit, or something else). Filter sends an error response immidetetly, but client reads the response only when the full request body is commited.

It seems that it is impossible to manually send something instead of 100 Continue status, when some check fails, and this behavior is hardcoded into tomcat, is there any other way not to upload request body, when it is impossible?


Solution

  • You need a servlet container with a more sane 100-continue handling (I believe jetty qualifies).

    I can't believe this clarification still isn't part of the servlet spec; I believe I asked for it something like 7 years ago.