Win a copy of Bad Programming Practices 101 (e-book) this week in the Beginning Java forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Tomcat responds without reading full request  RSS feed

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am sending ~10MB data to Tomcat through PUT call. I have increased POST size allowed on Tomcat. However, in the middle of sending that data, my Spring Security returns an authorization error (which is a valid error as per application logic). The client does not notice this and keeps sending data to the server which eventually resets the connection. My question is whether some setting in Tomcat by default starts 'streaming' data to controller servlet as soon as the client starts sending request? Else, what makes it not wait for full data before sending response?

Server number:  7.0.77.0

Thanks,
Sumit
 
Bartender
Posts: 19558
90
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
PUT and POST are two different types of call.

In PUT, the data is part of the URL. In POST, the data is in the request body. Most notably, there's an upper limit on how big a URL can be, although it's not predictable. At one time, it was as small as 2K.

Unless you "chunk" your request, the standard for HTTP is to push the entire POST request to the server before the application can handle it. At the server (Tomcat) level, a data limit or (apparently early processing of the URL part of the request) can cause Tomcat to shut down the receiving socket request. I've never looked at the details, since it's never been important to me.

From what I've seen, the net effect of a long POST request is that Tomcat stores everything either in RAM or an unknown temporary file until the entire (unchunked) POST is received and only then is the request dispatched to the webapp, which can then use J2EE API calls to pull the long data from whatever secret storage it's in and put it someplace where the webapp can work with it.

Actually, a quick check to refresh my memory and it looks like HTTP chunking is only for responses, not requests. So you may not have that option directly. There are ways to chunk manually using AJAX on the client, though. It's how the web controls that show upload progress work. Normally an upload goes straight from 0% to 100% with nothing in between, but AJAX chunking code can break up the data and in the process, update the client GUI.
 
Sheriff
Posts: 21378
91
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Tim Holloway wrote:In PUT, the data is part of the URL.


No it's not, it's in the body just like with POST (or at least, it should be). POST and PUT are requests that can contain a request body, GET and DELETE aren't.
 
Tim Holloway
Bartender
Posts: 19558
90
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Whoops. Sorry about that. It's been a while since I worked at that level. But PUT and POST are different. PUT is supposed to be idempotent.

Everything else I said should be more or less correct, though.
 
If I'd had more time, I would have written a shorter letter. -T.S. Eliot such a short, tiny ad:
Why should you try IntelliJ IDEA ?
https://coderanch.com/wiki/696337/IntelliJ-IDEA
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!