• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Tomcat responds without reading full request

 
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
 
Saloon Keeper
Posts: 22273
151
Android Eclipse IDE Tomcat Server Redhat Java 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: 21972
106
Eclipse IDE Spring VI Editor Chrome Java Ubuntu 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
Saloon Keeper
Posts: 22273
151
Android Eclipse IDE Tomcat Server Redhat Java 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.
 
Ew. You guys are ugly with a capital UG. Here, maybe this tiny ad can help:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic