private static String getXForwardedHeader ( StaplerRequest req , String header , String defaultValue ) { String value = req . getHeader ( header ) ; if ( value != null ) { int index = value . indexOf ( ' ' ) ; return index == - 1 ? value . trim ( ) : value . substring ( 0 , index ) . trim ( ) ; } return defaultValue ; }
Gets the originating X - Forwarded - ... header from the request . If there are multiple headers the originating header is the first header . If the originating header contains a comma separated list the originating entry is the first one .