public static String getShortRequestDump ( String fromMethod , boolean includeHeaders , HttpServletRequest request ) { StringBuilder dump = new StringBuilder ( ) ; dump . append ( "Timestamp : " ) . append ( ISO8601 . getTimestamp ( ) ) . append ( "\n" ) ; dump . append ( "fromMethod : " ) . append ( fromMethod ) . append ( "\n" ) ; dump . append ( "Method : " ) . append ( request . getMethod ( ) ) . append ( ' ' ) ; dump . append ( "Scheme : " ) . append ( request . getScheme ( ) ) . append ( ' ' ) ; dump . append ( "URI : " ) . append ( request . getRequestURI ( ) ) . append ( ' ' ) ; dump . append ( "Query-String : " ) . append ( request . getQueryString ( ) ) . append ( ' ' ) ; dump . append ( "Auth-Type : " ) . append ( request . getAuthType ( ) ) . append ( ' ' ) ; dump . append ( "Remote-Addr : " ) . append ( request . getRemoteAddr ( ) ) . append ( ' ' ) ; dump . append ( "Scheme : " ) . append ( request . getScheme ( ) ) . append ( ' ' ) ; dump . append ( "Content-Type : " ) . append ( request . getContentType ( ) ) . append ( ' ' ) ; dump . append ( "Content-Length: " ) . append ( request . getContentLength ( ) ) . append ( ' ' ) ; if ( includeHeaders ) { dump . append ( "Headers :\n" ) ; Enumeration < String > headers = request . getHeaderNames ( ) ; while ( headers . hasMoreElements ( ) ) { String header = headers . nextElement ( ) ; dump . append ( "\t" ) . append ( header ) . append ( ": " ) . append ( request . getHeader ( header ) ) . append ( ' ' ) ; } } return ( dump . toString ( ) ) ; }
Build a String containing a short multi - line dump of an HTTP request .