public void applyTo ( final HttpServletResponse sresp ) throws IOException { final Iterator < String > head = this . rsp . head ( ) . iterator ( ) ; final Matcher matcher = ResponseOf . HTTP_MATCHER . matcher ( head . next ( ) ) ; if ( matcher . matches ( ) ) { sresp . setStatus ( Integer . parseInt ( matcher . group ( 1 ) ) ) ; while ( head . hasNext ( ) ) { ResponseOf . applyHeader ( sresp , head . next ( ) ) ; } try ( InputStream body = this . rsp . body ( ) ; OutputStream out = sresp . getOutputStream ( ) ) { final byte [ ] buff = new byte [ ResponseOf . BUFSIZE ] ; // @checkstyle LineLengthCheck (1 line) for ( int read = body . read ( buff ) ; read >= 0 ; read = body . read ( buff ) ) { out . write ( buff ) ; } } } else { throw new IOException ( "Invalid response: response code not found" ) ; } }
Apply to servlet response .