Re: AW: AW: How to cancel upload?
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Steffen, On 8/21/2011 9:21 AM, Steffen Heil (Mailinglisten) wrote: Hi Actually, I'm not entirely correct and I am now remembering this has been discussed before on either this list or the tomcat-dev list. Do you remember anything else about that thread? Something that might help me find it... ? I've been looking for it, too, since I know it's been discussed. There's this from users@ http://markmail.org/thread/vlebky5z6hl6wdjj and this from dev@ (which is more recent) http://markmail.org/thread/qpdza5qz4ziigkx5 Are you throwing an exception, or closing the inputstream? I tried to throw an exception (IOException) but it seemed tomcat would then read the stream for me. Right, Tomcat will drain the InputStream for you. That provides a nicer experience for a client that would otherwise receive a nasty error (because the server hangs up before the complete request has been made). I tried to close the inputstream I got from ServletUpload, I think I did not try to close request.getInputStream() yet. I will try. Are you able to force the clients to use Expect/Continue? Client: PUT /foo/bar HTTP/1.1 Expect: 100-continue Content-Length: 1234567890 Content-Type: image/jpeg Server: 100 Continue (or some error code) I'm not sure if you can determine merely from the headers whether or not the request is going to be valid, so this might not be an option for you. Or, you may have dumb (software) clients that can't be asked to use Expect/Continue in this way. - -chris -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk5TsjMACgkQ9CaO5/Lv0PDZuQCgj4/ogEJEc3FyoaYY//57LNdn hRcAoLp5hv8843erB8ZKgDwG+OLMFWX6 =LvX6 -END PGP SIGNATURE- - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
AW: How to cancel upload?
Hi Short question: How can I prevent tomcat to receive the complete post data? Stop sending the data before it's all been sent. Sorry, I don't understand what you mean. If you mean to send only small parts and only those that are wanted, that's nothing I can do. I need to support the upload of really huge files (tested up to 9 GB so far and need to go beyond), while I cannot allow any user to block the complete bandwidth by uploading gigabytes of files that are not wanted - which I can usually detect within the first few bytes. And the thing they are uploading is exactly one file... The browser cannot split them. AFAIK Tomcat processes the request before the user code in a servlet is active, so you can't do it from inside a servlet. Hm. Tomcat does NOT parse these POST parameters (at least not by default and not in my case). I know for sure, that my code detects unwanted files with only a few bytes received. (I can tell by printing a simple line to the logs, and I can see that line nearly immediately after starting a 9GB upload, yet the browser continues to upload everything.) I just cannot cancel the upload. Regards, Steffen smime.p7s Description: S/MIME cryptographic signature
Re: AW: How to cancel upload?
On 21/08/2011 08:08, Steffen Heil (Mailinglisten) wrote: AFAIK Tomcat processes the request before the user code in a servlet is active, so you can't do it from inside a servlet. Hm. Tomcat does NOT parse these POST parameters (at least not by default and not in my case). I know for sure, that my code detects unwanted files with only a few bytes received. (I can tell by printing a simple line to the logs, and I can see that line nearly immediately after starting a 9GB upload, yet the browser continues to upload everything.) I just cannot cancel the upload. Actually, I'm not entirely correct and I am now remembering this has been discussed before on either this list or the tomcat-dev list. Are you throwing an exception, or closing the inputstream? p signature.asc Description: OpenPGP digital signature
AW: AW: How to cancel upload?
Hi Actually, I'm not entirely correct and I am now remembering this has been discussed before on either this list or the tomcat-dev list. Do you remember anything else about that thread? Something that might help me find it... ? Are you throwing an exception, or closing the inputstream? I tried to throw an exception (IOException) but it seemed tomcat would then read the stream for me. I tried to close the inputstream I got from ServletUpload, I think I did not try to close request.getInputStream() yet. I will try. Regards, Steffen smime.p7s Description: S/MIME cryptographic signature
Re: How to cancel upload?
On 19/08/2011 14:37, Steffen Heil (Mailinglisten) wrote: Hi Short question: How can I prevent tomcat to receive the complete post data? Stop sending the data before it's all been sent. Long question: I have a servlet that uses apache commons fileupload to process incoming uploads using the streaming api. Short version of the code: InputStream inputStream; try { ServletFileUpload upload = new ServletFileUpload(); iterator = upload.getItemIterator( request ); if ( ! iterator.hasNext() ) return; FileItemStream item = iterator.next(); if ( item.isFormField() || ! file.equals( item.getFieldName() ) ) return; inputStream = item.openStream(); use( inputStream ) } finally { try { inputStream.close(); } catch ( Throwable ignored ) { // just ignore } } Now, the method use(InputStream) may decide that this file is not wanted and may NOT read the inputstream fully. Or there may be more field, that I am not interested in. I want to abort reading the request, as there may be several hundred megabytes of data coming. However inputStream.close() in FileItemStream seams to read everything that follows. So I tried not to close that steam. Still some component read everything, I suspect tomcat did so - to allow keepalive connections. Then I tried to throw an IOException, but no change. So my question is: How can I prevent tomcat to receive the complete post data? AFAIK Tomcat processes the request before the user code in a servlet is active, so you can't do it from inside a servlet. Someone will correct me if I'm wrong... p signature.asc Description: OpenPGP digital signature
How to cancel upload?
Hi Short question: How can I prevent tomcat to receive the complete post data? Long question: I have a servlet that uses apache commons fileupload to process incoming uploads using the streaming api. Short version of the code: InputStream inputStream; try { ServletFileUpload upload = new ServletFileUpload(); iterator = upload.getItemIterator( request ); if ( ! iterator.hasNext() ) return; FileItemStream item = iterator.next(); if ( item.isFormField() || ! file.equals( item.getFieldName() ) ) return; inputStream = item.openStream(); use( inputStream ) } finally { try { inputStream.close(); } catch ( Throwable ignored ) { // just ignore } } Now, the method use(InputStream) may decide that this file is not wanted and may NOT read the inputstream fully. Or there may be more field, that I am not interested in. I want to abort reading the request, as there may be several hundred megabytes of data coming. However inputStream.close() in FileItemStream seams to read everything that follows. So I tried not to close that steam. Still some component read everything, I suspect tomcat did so - to allow keepalive connections. Then I tried to throw an IOException, but no change. So my question is: How can I prevent tomcat to receive the complete post data? Regards, Steffen smime.p7s Description: S/MIME cryptographic signature