javaguy Posted August 20, 2010 Report Share Posted August 20, 2010 Need some advice from anybody here who might be a networking/Java guru. I'm working on a Java app that uses Apache/Tomcat and to which the users sometimes upload files. I know that Apache can be configured with a maximum file upload size, but this application needs to allow some users to upload certain file sizes and others a different size. The request header contains a content-length attribute that can be used to check the request size. The problem is that by the time the servlet is processing the request and can look at this information, the entire file has been uploaded. So a user might upload a huge file and then, after waiting, be told that his file is too big and has been discarded. What I'd really like is to peek at the request header as the request first starts coming in and close the connection if the file is too big. I considered writing a custom Valve for Tomcat, but it looks to me like a Valve also does not process a request until the entire request has been received. My next thought is to customize some kind of proxy between Apache and Tomcat. Is there any way that a Java component can be put in the pipeline to sniff out request headers and parse the content-length? (I'm assuming that Apache pipes requests through to Tomcat as they come in, rather than waiting for the entire request body and then passing it on. I think that's a reasonable assumption but really don't know.) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.