rburgst / okhttp-digest

a digest authenticator for okhttp
Apache License 2.0
191 stars 42 forks source link

https #48

Closed houziershi closed 6 years ago

houziershi commented 6 years ago

final DigestAuthenticator authenticator = new DigestAuthenticator(new Credentials(unicomUserName, unicomPassword));

    final Map<String, CachingAuthenticator> authCache = new ConcurrentHashMap<>();
    final OkHttpClient client = new OkHttpClient.Builder()
            .proxy(new Proxy(Proxy.Type.HTTP, new InetSocketAddress(unicomProxyHost, 8143))) //https:8143
            .authenticator(new CachingAuthenticatorDecorator(authenticator, authCache))
            .addInterceptor(new AuthenticationCacheInterceptor(authCache))
            .build();

// String url = "http://www.google.com"; Request request = new Request.Builder() .url(unicomUrl) .build(); try (Response response = client.newCall(request).execute()) {

        return response.body().string();
    }

use proxy and digest lead to error: Process: com.example.admin.mydemo, PID: 13867 java.lang.IllegalStateException: closed at okio.RealBufferedSource.rangeEquals(RealBufferedSource.java:398) at okio.RealBufferedSource.rangeEquals(RealBufferedSource.java:392) at okhttp3.internal.Util.bomAwareCharset(Util.java:431) at okhttp3.ResponseBody.string(ResponseBody.java:174) at com.example.admin.mydemo.MainActivity.unicomHttpRequest(MainActivity.java:258) at com.example.admin.mydemo.MainActivity.access$000(MainActivity.java:32) at com.example.admin.mydemo.MainActivity$1.run(MainActivity.java:85) at java.lang.Thread.run(Thread.java:761)

houziershi commented 6 years ago

error bug.