Skip to content

Commit b455a94

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

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
@@ -853,14 +853,17 @@ private boolean sendAsGrizzlyRequest(final Request request,
853853
boolean secure = "https".equals(uri.getScheme());
854854
builder.method(method);
855855
builder.protocol(Protocol.HTTP_1_1);
856-
String host = request.getVirtualHost();
857-
if (host != null) {
858-
builder.header(Header.Host, host);
859-
} else {
860-
if (uri.getPort() == -1) {
861-
builder.header(Header.Host, uri.getHost());
856+
857+
if (!request.getHeaders().containsKey(Header.Host.toString())) {
858+
String host = request.getVirtualHost();
859+
if (host != null) {
860+
builder.header(Header.Host, host);
862861
} else {
863-
builder.header(Header.Host, uri.getHost() + ':' + uri.getPort());
862+
if (uri.getPort() == -1) {
863+
builder.header(Header.Host, uri.getHost());
864+
} else {
865+
builder.header(Header.Host, uri.getHost() + ':' + uri.getPort());
866+
}
864867
}
865868
}
866869
final ProxyServer proxy = ProxyUtils.getProxyServer(config, request);

0 commit comments

Comments
 (0)