public static void copy ( HttpServletRequest req , OutputStream output ) throws IOException { InputStream input = req . getInputStream ( ) ; int availableBytes = req . getContentLength ( ) ; log . debug ( "copy - available: {}" , availableBytes ) ; if ( availableBytes > 0 ) { byte [ ] buf = new byte [ availableBytes ] ; int bytesRead = input . read ( buf ) ; while ( bytesRead != - 1 ) { output . write ( buf , 0 , bytesRead ) ; bytesRead = input . read ( buf ) ; log . trace ( "Bytes read: {}" , bytesRead ) ; } output . flush ( ) ; } else { log . debug ( "Nothing to available to copy" ) ; } }
Copies information from the http request to the output stream using the specified content length .