private static Map < String , String > __getRequestHeaderMap ( HttpServletRequest req ) { Map < String , String > reqHeaders = new LinkedHashMap <> ( ) ; Enumeration < String > headerNames = req . getHeaderNames ( ) ; if ( headerNames != null ) { while ( headerNames . hasMoreElements ( ) ) { String headerName = headerNames . nextElement ( ) ; Enumeration < String > headerValues = req . getHeaders ( headerName ) ; if ( headerValues != null ) { StringBuilder headerValueBuilder = new StringBuilder ( ) ; int i = 0 ; while ( headerValues . hasMoreElements ( ) ) { if ( i > 0 ) { headerValueBuilder . append ( ", " ) ; } headerValueBuilder . append ( headerValues . nextElement ( ) ) ; i ++ ; } reqHeaders . put ( headerName , headerValueBuilder . toString ( ) ) ; } else { reqHeaders . put ( headerName , "" ) ; } } } return reqHeaders ; }
Retrive a map containing the request headers associated with given request .