Skip to content

Commit

Permalink
Don't set port in Host header when it's the scheme's default one, close
Browse files Browse the repository at this point in the history
  • Loading branch information
slandelle committed Jun 1, 2015
1 parent 67b80cf commit cf88732
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
Expand Up @@ -14,11 +14,7 @@
package org.asynchttpclient.netty.request;

import static org.asynchttpclient.ntlm.NtlmUtils.getNTLM;
import static org.asynchttpclient.util.AsyncHttpProviderUtils.DEFAULT_CHARSET;
import static org.asynchttpclient.util.AsyncHttpProviderUtils.getAuthority;
import static org.asynchttpclient.util.AsyncHttpProviderUtils.getNonEmptyPath;
import static org.asynchttpclient.util.AsyncHttpProviderUtils.keepAliveHeaderValue;
import static org.asynchttpclient.util.AsyncHttpProviderUtils.urlEncodeFormParams;
import static org.asynchttpclient.util.AsyncHttpProviderUtils.*;
import static org.asynchttpclient.util.AuthenticatorUtils.computeBasicAuthentication;
import static org.asynchttpclient.util.AuthenticatorUtils.computeDigestAuthentication;
import static org.asynchttpclient.util.HttpUtils.isSecure;
Expand All @@ -34,8 +30,8 @@

import org.asynchttpclient.AsyncHttpClientConfig;
import org.asynchttpclient.Realm;
import org.asynchttpclient.Request;
import org.asynchttpclient.Realm.AuthScheme;
import org.asynchttpclient.Request;
import org.asynchttpclient.cookie.CookieEncoder;
import org.asynchttpclient.netty.request.body.NettyBody;
import org.asynchttpclient.netty.request.body.NettyBodyBody;
Expand Down Expand Up @@ -88,7 +84,8 @@ else if (proxyServer != null && !useProxyConnect(uri))

private String hostHeader(Request request, Uri uri) {
String host = request.getVirtualHost() != null ? request.getVirtualHost() : uri.getHost();
return request.getVirtualHost() != null || uri.getPort() == -1 ? host : host + ":" + uri.getPort();
int port = uri.getPort();
return port == -1 || port == getDefaultPort(uri) ? host : host + ":" + port;
}

public String firstRequestOnlyAuthorizationHeader(Request request, Uri uri, ProxyServer proxyServer, Realm realm) throws IOException {
Expand Down
Expand Up @@ -14,11 +14,7 @@
package org.asynchttpclient.netty.request;

import static org.asynchttpclient.ntlm.NtlmUtils.getNTLM;
import static org.asynchttpclient.util.AsyncHttpProviderUtils.DEFAULT_CHARSET;
import static org.asynchttpclient.util.AsyncHttpProviderUtils.getAuthority;
import static org.asynchttpclient.util.AsyncHttpProviderUtils.getNonEmptyPath;
import static org.asynchttpclient.util.AsyncHttpProviderUtils.keepAliveHeaderValue;
import static org.asynchttpclient.util.AsyncHttpProviderUtils.urlEncodeFormParams;
import static org.asynchttpclient.util.AsyncHttpProviderUtils.*;
import static org.asynchttpclient.util.AuthenticatorUtils.computeBasicAuthentication;
import static org.asynchttpclient.util.AuthenticatorUtils.computeDigestAuthentication;
import static org.asynchttpclient.util.HttpUtils.isSecure;
Expand All @@ -41,8 +37,8 @@

import org.asynchttpclient.AsyncHttpClientConfig;
import org.asynchttpclient.Realm;
import org.asynchttpclient.Request;
import org.asynchttpclient.Realm.AuthScheme;
import org.asynchttpclient.Request;
import org.asynchttpclient.cookie.CookieEncoder;
import org.asynchttpclient.netty.request.body.NettyBody;
import org.asynchttpclient.netty.request.body.NettyBodyBody;
Expand Down Expand Up @@ -89,7 +85,8 @@ else if (proxyServer != null && !useProxyConnect(uri))

private String hostHeader(Request request, Uri uri) {
String host = request.getVirtualHost() != null ? request.getVirtualHost() : uri.getHost();
return request.getVirtualHost() != null || uri.getPort() == -1 ? host : host + ":" + uri.getPort();
int port = uri.getPort();
return port == -1 || port == getDefaultPort(uri) ? host : host + ":" + port;
}

public String firstRequestOnlyAuthorizationHeader(Request request, Uri uri, ProxyServer proxyServer, Realm realm) throws IOException {
Expand Down

0 comments on commit cf88732

Please sign in to comment.