public void addHeaders ( HttpServletRequest reqSource , HttpRequestBase httpTarget ) { Enumeration < ? > headerNames = reqSource . getHeaderNames ( ) ; while ( headerNames . hasMoreElements ( ) ) { String key = headerNames . nextElement ( ) . toString ( ) ; if ( CONTENT_LENGTH . equalsIgnoreCase ( key ) ) continue ; // Length will be different Enumeration < ? > headers = reqSource . getHeaders ( key ) ; while ( headers . hasMoreElements ( ) ) { String value = ( String ) headers . nextElement ( ) ; if ( HOST . equalsIgnoreCase ( key ) ) { value = proxyURLPrefix ; if ( value . indexOf ( ":" ) != - 1 ) { value = value . substring ( value . indexOf ( ":" ) + 1 ) ; while ( value . startsWith ( "/" ) ) { value = value . substring ( 1 ) ; } } if ( value . indexOf ( "/" ) != - 1 ) value = value . substring ( 0 , value . indexOf ( "/" ) ) ; } httpTarget . setHeader ( new BasicHeader ( key , value ) ) ; } } }
Move the header info to the proxy request .