public void handle ( HttpServletRequest request , HttpServletResponse response ) throws IOException { logger . debug ( "Handling HttpServletRequest {}" , request ) ; response . setContentType ( contentType ) ; OutputStream output = response . getOutputStream ( ) ; InputStream input = getRequestStream ( request ) ; int result = ErrorResolver . JsonError . PARSE_ERROR . code ; int contentLength = 0 ; ByteArrayOutputStream byteOutput = new ByteArrayOutputStream ( ) ; try { String acceptEncoding = request . getHeader ( ACCEPT_ENCODING ) ; result = handleRequest0 ( input , output , acceptEncoding , response , byteOutput ) ; contentLength = byteOutput . size ( ) ; } catch ( Throwable t ) { if ( StreamEndedException . class . isInstance ( t ) ) { logger . debug ( "Bad request: empty contents!" ) ; } else { logger . error ( t . getMessage ( ) , t ) ; } } int httpStatusCode = httpStatusCodeProvider == null ? DefaultHttpStatusCodeProvider . INSTANCE . getHttpStatusCode ( result ) : httpStatusCodeProvider . getHttpStatusCode ( result ) ; response . setStatus ( httpStatusCode ) ; response . setContentLength ( contentLength ) ; byteOutput . writeTo ( output ) ; output . flush ( ) ; }
Handles a servlet request .