public void doProgressText ( StaplerRequest req , StaplerResponse rsp ) throws IOException { rsp . setContentType ( "text/plain" ) ; rsp . setStatus ( HttpServletResponse . SC_OK ) ; if ( ! source . exists ( ) ) { // file doesn't exist yet rsp . addHeader ( "X-Text-Size" , "0" ) ; rsp . addHeader ( "X-More-Data" , "true" ) ; return ; } long start = 0 ; String s = req . getParameter ( "start" ) ; if ( s != null ) start = Long . parseLong ( s ) ; if ( source . length ( ) < start ) start = 0 ; // text rolled over CharSpool spool = new CharSpool ( ) ; long r = writeLogTo ( start , spool ) ; rsp . addHeader ( "X-Text-Size" , String . valueOf ( r ) ) ; if ( ! completed ) rsp . addHeader ( "X-More-Data" , "true" ) ; // when sending big text, try compression. don't bother if it's small Writer w ; if ( r - start > 4096 ) w = rsp . getCompressedWriter ( req ) ; else w = rsp . getWriter ( ) ; spool . writeTo ( new LineEndNormalizingWriter ( w ) ) ; w . close ( ) ; }
Implements the progressive text handling . This method is used as a web method with progressiveText . jelly .