Skip to content

Commit

Permalink
Fixes #4808 - Review HttpClient Request header APIs.
Browse files Browse the repository at this point in the history
Fixed test failures.

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
  • Loading branch information
sbordet committed May 5, 2020
1 parent cf9df70 commit a93b2c6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public <T extends ResponseListener> List<T> getListeners(Class<T> type)

public HttpFields getTrailers()
{
return trailers.asImmutable();
return trailers == null ? null : trailers.asImmutable();
}

public HttpResponse trailer(HttpField trailer)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -538,8 +538,12 @@ protected void addXForwardedHeaders(HttpServletRequest clientRequest, Request pr
{
proxyRequest.headers(headers -> headers.add(HttpHeader.X_FORWARDED_FOR, clientRequest.getRemoteAddr()));
proxyRequest.headers(headers -> headers.add(HttpHeader.X_FORWARDED_PROTO, clientRequest.getScheme()));
proxyRequest.headers(headers -> headers.add(HttpHeader.X_FORWARDED_HOST, clientRequest.getHeader(HttpHeader.HOST.asString())));
proxyRequest.headers(headers -> headers.add(HttpHeader.X_FORWARDED_SERVER, clientRequest.getLocalName()));
String hostHeader = clientRequest.getHeader(HttpHeader.HOST.asString());
if (hostHeader != null)
proxyRequest.headers(headers -> headers.add(HttpHeader.X_FORWARDED_HOST, hostHeader));
String localName = clientRequest.getLocalName();
if (localName != null)
proxyRequest.headers(headers -> headers.add(HttpHeader.X_FORWARDED_SERVER, localName));
}

protected void sendProxyRequest(HttpServletRequest clientRequest, HttpServletResponse proxyResponse, Request proxyRequest)
Expand Down

0 comments on commit a93b2c6

Please sign in to comment.