• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Tomcat responds without reading full request

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Saloon Keeper
Posts: 27763
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Saloon Keeper
Posts: 27763
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Blood pressure normal? What do I change to get "magnificent"? Maybe this tiny ad?
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic