Skip to content

Commit 7732db4

Browse files
committed
Fix for #AHC-117
1 parent 893d079 commit 7732db4

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/main/java/com/ning/http/client/providers/netty/NettyAsyncHttpProvider.java

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -492,12 +492,16 @@ public void operationComplete(ChannelFuture cf) {
492492
}
493493

494494
}
495+
496+
private static boolean isProxyServer(AsyncHttpClientConfig config, Request request) {
497+
return request.getProxyServer() != null || config.getProxyServer() != null;
498+
}
495499

496500
protected final static HttpRequest buildRequest(AsyncHttpClientConfig config, Request request, URI uri,
497501
boolean allowConnect, ChannelBuffer buffer) throws IOException {
498502

499503
String method = request.getMethod();
500-
if (allowConnect && ((request.getProxyServer() != null || config.getProxyServer() != null) && HTTPS.equalsIgnoreCase(uri.getScheme()))) {
504+
if (allowConnect && (isProxyServer(config, request) && HTTPS.equalsIgnoreCase(uri.getScheme()))) {
501505
method = HttpMethod.CONNECT.toString();
502506
}
503507
return construct(config, request, new HttpMethod(method), uri, buffer);
@@ -520,9 +524,14 @@ private static HttpRequest construct(AsyncHttpClientConfig config,
520524
if (m.equals(HttpMethod.CONNECT)) {
521525
nettyRequest = new DefaultHttpRequest(HttpVersion.HTTP_1_0, m, AsyncHttpProviderUtils.getAuthority(uri));
522526
} else {
523-
StringBuilder path = new StringBuilder(uri.getRawPath());
524-
if (uri.getQuery() != null) {
525-
path.append("?").append(uri.getRawQuery());
527+
StringBuilder path = null;
528+
if(isProxyServer(config, request))
529+
path = new StringBuilder(uri.toString());
530+
else {
531+
path = new StringBuilder(uri.getRawPath());
532+
if (uri.getQuery() != null) {
533+
path.append("?").append(uri.getRawQuery());
534+
}
526535
}
527536
nettyRequest = new DefaultHttpRequest(HttpVersion.HTTP_1_1, m, path.toString());
528537
}

0 commit comments

Comments
 (0)