-
Notifications
You must be signed in to change notification settings - Fork 9.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
okhttp proxy https is failed #3782
Comments
Hello! |
Yes, I fixed this bug, but I have to change the source code
OKHttp3.9.1,I watch the source code and debug it,I found the createTunnelRequestnot add the Proxy-Authorization,so The https request is can not be connected
@Navi91 I hope for your help |
@zi6xuan Thank you for reply! |
@zi6xuan This problem can only be solved by modifying the source code? |
version: okhttp-3.9.1
os: Windows7,AndroidEmulator25,26
compileSDKVersion: 26
i set the proxy for okhttp,and request "https://www.google.com",but get a error now.
don't set proxy it's can work
mProxyAuthenticator = new Authenticator() {
@Override
public Request authenticate(Route route, Response response) throws IOException {
String credential = Credentials.basic(username, password);
return response.request().newBuilder()
.header("Proxy-Authorization", credential)
.build();
}
};
mInetSocketAdress = new InetSocketAddress(proxyHost, proxyPort);
OkHttpClient.Builder builder = new OkHttpClient().newBuilder();
builder.proxy(new Proxy(Proxy.Type.HTTP, mInetSocketAdress))
.proxyAuthenticator(mProxyAuthenticator);
Request request = new Request.Builder()
.url(url)
.build();
OkHttpClient client = builder.build();
response = client.newCall(request).execute();
....
errors
01-18 01:00:12.088 4338-4449/com.nttd.app.CarCooperation W/System.err: java.io.IOException: unexpected end of stream on null
01-18 01:00:12.088 4338-4449/com.nttd.app.CarCooperation W/System.err: at okhttp3.internal.http1.Http1Codec.readResponseHeaders(Http1Codec.java:205)
01-18 01:00:12.088 4338-4449/com.nttd.app.CarCooperation W/System.err: at okhttp3.internal.connection.RealConnection.createTunnel(RealConnection.java:354)
01-18 01:00:12.088 4338-4449/com.nttd.app.CarCooperation W/System.err: at okhttp3.internal.connection.RealConnection.connectTunnel(RealConnection.java:211)
01-18 01:00:12.088 4338-4449/com.nttd.app.CarCooperation W/System.err: at okhttp3.internal.connection.RealConnection.connect(RealConnection.java:152)
01-18 01:00:12.088 4338-4449/com.nttd.app.CarCooperation W/System.err: at okhttp3.internal.connection.StreamAllocation.findConnection(StreamAllocation.java:256)
01-18 01:00:12.088 4338-4449/com.nttd.app.CarCooperation W/System.err: at okhttp3.internal.connection.StreamAllocation.findHealthyConnection(StreamAllocation.java:134)
01-18 01:00:12.088 4338-4449/com.nttd.app.CarCooperation W/System.err: at okhttp3.internal.connection.StreamAllocation.newStream(StreamAllocation.java:113)
01-18 01:00:12.088 4338-4449/com.nttd.app.CarCooperation W/System.err: at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:42)
01-18 01:00:12.088 4338-4449/com.nttd.app.CarCooperation W/System.err: at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
01-18 01:00:12.088 4338-4449/com.nttd.app.CarCooperation W/System.err: at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
01-18 01:00:12.089 4338-4449/com.nttd.app.CarCooperation W/System.err: at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:93)
01-18 01:00:12.089 4338-4449/com.nttd.app.CarCooperation W/System.err: at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
01-18 01:00:12.089 4338-4449/com.nttd.app.CarCooperation W/System.err: at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
01-18 01:00:12.089 4338-4449/com.nttd.app.CarCooperation W/System.err: at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
01-18 01:00:12.089 4338-4449/com.nttd.app.CarCooperation W/System.err: at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
01-18 01:00:12.089 4338-4449/com.nttd.app.CarCooperation W/System.err: at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:125)
01-18 01:00:12.089 4338-4449/com.nttd.app.CarCooperation W/System.err: at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
01-18 01:00:12.089 4338-4449/com.nttd.app.CarCooperation W/System.err: at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
01-18 01:00:12.089 4338-4449/com.nttd.app.CarCooperation W/System.err: at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:200)
01-18 01:00:12.089 4338-4449/com.nttd.app.CarCooperation W/System.err: at okhttp3.RealCall.execute(RealCall.java:77)
01-18 01:00:12.089 4338-4449/com.nttd.app.CarCooperation W/System.err: at com.nttd.app.CarCooperation.http.HttpManager$4.run(HttpManager.java:164)
01-18 01:00:12.089 4338-4449/com.nttd.app.CarCooperation W/System.err: at java.lang.Thread.run(Thread.java:761)
01-18 01:00:12.089 4338-4449/com.nttd.app.CarCooperation W/System.err: Caused by: java.io.EOFException: \n not found: limit=0 content=…
01-18 01:00:12.089 4338-4449/com.nttd.app.CarCooperation W/System.err: at okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.java:227)
01-18 01:00:12.089 4338-4449/com.nttd.app.CarCooperation W/System.err: at okhttp3.internal.http1.Http1Codec.readHeaderLine(Http1Codec.java:212)
01-18 01:00:12.089 4338-4449/com.nttd.app.CarCooperation W/System.err: at okhttp3.internal.http1.Http1Codec.readResponseHeaders(Http1Codec.java:189)
01-18 01:00:12.089 4338-4449/com.nttd.app.CarCooperation W/System.err: ... 21 more
then I try the HttpClient API,same the network,get the message
httpClient=Code=407 Proxy Authentication Required
why the OKhttp not back the code 407
The text was updated successfully, but these errors were encountered: