public void extractHttpRequestInfo ( HttpServletRequest httpRequest ) { putUnlessNull ( REQUEST_REFERER_URL , httpRequest . getHeader ( "REFERER" ) ) ; String remoteAddr = httpRequest . getHeader ( "X-Forwarded-For" ) ; remoteAddr = ( remoteAddr == null ) ? httpRequest . getRemoteAddr ( ) : remoteAddr + ", " + httpRequest . getRemoteAddr ( ) ; putUnlessNull ( REQUEST_REMOTE_ADDRESS , remoteAddr ) ; // Check for AJAX String x_req_with = httpRequest . getHeader ( "X-Requested-With" ) ; if ( x_req_with != null ) { if ( x_req_with . equals ( "XMLHttpRequest" ) ) { this . setAjaxRequest ( true ) ; } } else if ( this . getRefererUrl ( ) != null && httpRequest . getParameter ( "ajaxpipe" ) != null ) { this . setAjaxRequest ( true ) ; } if ( isMementoEnabled ( ) ) { // Check for Memento Accept-Datetime String acceptDateTime = httpRequest . getHeader ( MementoUtils . ACCEPT_DATETIME ) ; if ( acceptDateTime != null ) { this . setMementoAcceptDatetime ( true ) ; } } putUnlessNull ( REQUEST_WAYBACK_HOSTNAME , httpRequest . getLocalName ( ) ) ; putUnlessNull ( REQUEST_AUTH_TYPE , httpRequest . getAuthType ( ) ) ; putUnlessNull ( REQUEST_REMOTE_USER , httpRequest . getRemoteUser ( ) ) ; putUnlessNull ( REQUEST_AUTHORIZATION , httpRequest . getHeader ( REQUEST_AUTHORIZATION ) ) ; putUnlessNull ( REQUEST_WAYBACK_PORT , String . valueOf ( httpRequest . getLocalPort ( ) ) ) ; putUnlessNull ( REQUEST_WAYBACK_CONTEXT , httpRequest . getContextPath ( ) ) ; Locale l = null ; if ( accessPoint != null ) { l = accessPoint . getLocale ( ) ; } if ( l == null ) { l = httpRequest . getLocale ( ) ; } //setLocale(l); this . locale = l ; putUnlessNull ( REQUEST_LOCALE_LANG , l . getDisplayLanguage ( ) ) ; Cookie [ ] cookies = httpRequest . getCookies ( ) ; if ( cookies != null ) { for ( Cookie cookie : cookies ) { String name = cookie . getName ( ) ; String value = cookie . getValue ( ) ; String oldVal = get ( name ) ; if ( oldVal == null || oldVal . length ( ) == 0 ) { put ( name , value ) ; } } } }
extract REFERER remote IP and authorization information from the HttpServletRequest