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