Skip to content

Commit eace5fe

Browse files
author
oleksiys
committed
[1.8.x] + don't add another Host header if it's already set
1 parent ae87158 commit eace5fe

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/main/java/com/ning/http/client/providers/grizzly/GrizzlyAsyncHttpProvider.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -873,14 +873,17 @@ private boolean sendAsGrizzlyRequest(final Request request,
873873
boolean secure = "https".equals(uri.getScheme());
874874
builder.method(method);
875875
builder.protocol(Protocol.HTTP_1_1);
876-
String host = request.getVirtualHost();
877-
if (host != null) {
878-
builder.header(Header.Host, host);
879-
} else {
880-
if (uri.getPort() == -1) {
881-
builder.header(Header.Host, uri.getHost());
876+
877+
if (!request.getHeaders().containsKey(Header.Host.toString())) {
878+
String host = request.getVirtualHost();
879+
if (host != null) {
880+
builder.header(Header.Host, host);
882881
} else {
883-
builder.header(Header.Host, uri.getHost() + ':' + uri.getPort());
882+
if (uri.getPort() == -1) {
883+
builder.header(Header.Host, uri.getHost());
884+
} else {
885+
builder.header(Header.Host, uri.getHost() + ':' + uri.getPort());
886+
}
884887
}
885888
}
886889
final ProxyServer proxy = ProxyUtils.getProxyServer(config, request);

0 commit comments

Comments
 (0)