On 09/09/2019 16:41, Leon Atherton wrote:
> Our use case is rejecting the request based on IP.
> 
> In the browser the status code is 0, and the network tab in developer 
> tools is showing no response to the request. It's the same in Chrome and 
> Firefox.
> 
> The request works fine when I send from Node.JS.
> 
> It seems to me that Tomcat responds to the request before the upload has 
> completed, and calling request.getParameter() fixes the problem because 
> it causes Tomcat to read the full request before the response is sent.
> 
> Some clients are fine with the early response (e.g. Node.JS), but both 
> Chrome and Firefox don't like it.
> 
> I'm not sure if it's an issue with how Tomcat handles the request, or 
> how the browsers are handling the response (but I suspect it can be 
> fixed on the Tomcat side as the problem does not occur with Payara).

The configuration attribute you want is maxSwallowSize. You need to set
that to greater than the size of the uploaded file.

Clients could handle this better but many don't read the response until
the request is fully written.

Tomcat limit's maxSwallowSize as a DoS protection measure. Without it, a
client could just continue uploading a slow trickle of data and tie up a
server thread.

For the record, maPostSize applies *only* to requests using
application/x-www-form-urlencoded

The test provided by the OP uses multipart/form-data. The applicable
limits are defined by javax.servlet.annotation.MultipartConfig and the
defaults are unlimited.

Any call to getPart(), getParameter() and friends will trigger the
reading of the request body.

Hence, without the call to getParameter() Tomcat doesn't read the
request body. With small uploads there is enough network buffering
between the client and the server for the client to be able to write the
full request so it reads the response. (Tomcat's maxSwallowSize
effectively acts as a buffer.) With larger uploads the client fills the
buffers before the request is fully written so it never sees the response.

Increasing the maxSwallowSize will allow the client to write the full
request and then read the response.

Mark

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to