Skip to content

Commit 4237034

Browse files
committed
Don't force CONNECT on HTTP/1.0, add a ProxyServer parameter, close AsyncHttpClient#892
1 parent 8ad200f commit 4237034

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

api/src/main/java/org/asynchttpclient/ProxyServer.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ public String toString() {
6060
private String ntlmDomain = System.getProperty("http.auth.ntlm.domain", "");
6161
private String ntlmHost;
6262
private AuthScheme scheme = AuthScheme.BASIC;
63+
private boolean forceHttp10 = false;
6364

6465
public ProxyServer(final Protocol protocol, final String host, final int port, String principal, String password) {
6566
this.protocol = protocol;
@@ -162,6 +163,14 @@ public String getNtlmHost() {
162163
public void setNtlmHost(String ntlmHost) {
163164
this.ntlmHost = ntlmHost;
164165
}
166+
167+
public boolean isForceHttp10() {
168+
return forceHttp10;
169+
}
170+
171+
public void setForceHttp10(boolean forceHttp10) {
172+
this.forceHttp10 = forceHttp10;
173+
}
165174

166175
@Override
167176
public String toString() {

providers/netty3/src/main/java/org/asynchttpclient/providers/netty/request/NettyRequestFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ public NettyRequest newNettyRequest(Request request, Uri uri, boolean forceConne
269269
throws IOException {
270270

271271
HttpMethod method = forceConnect ? HttpMethod.CONNECT : HttpMethod.valueOf(request.getMethod());
272-
HttpVersion httpVersion = method == HttpMethod.CONNECT ? HttpVersion.HTTP_1_0 : HttpVersion.HTTP_1_1;
272+
HttpVersion httpVersion = method == HttpMethod.CONNECT && proxyServer.isForceHttp10() ? HttpVersion.HTTP_1_0 : HttpVersion.HTTP_1_1;
273273
String requestUri = requestUri(uri, proxyServer, method);
274274

275275
NettyBody body = body(request, method);

providers/netty4/src/main/java/org/asynchttpclient/providers/netty/request/NettyRequestFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ public void setProxyAuthorizationHeader(HttpHeaders headers, String proxyAuthori
267267
public NettyRequest newNettyRequest(Request request, Uri uri, boolean forceConnect, ProxyServer proxyServer) throws IOException {
268268

269269
HttpMethod method = forceConnect ? HttpMethod.CONNECT : HttpMethod.valueOf(request.getMethod());
270-
HttpVersion httpVersion = method == HttpMethod.CONNECT ? HttpVersion.HTTP_1_0 : HttpVersion.HTTP_1_1;
270+
HttpVersion httpVersion = method == HttpMethod.CONNECT && proxyServer.isForceHttp10() ? HttpVersion.HTTP_1_0 : HttpVersion.HTTP_1_1;
271271
String requestUri = requestUri(uri, proxyServer, method);
272272

273273
NettyBody body = body(request, method);

0 commit comments

Comments
 (0)