【发布时间】:2022-01-21 21:26:35
【问题描述】:
我有实现 Authenticator 接口的 ProxyAuthenticator 类。
public class ProxyAuthenticator implements Authenticator {
private String proxyUser;
private String proxyPassword;
public ProxyTessiAuthenticator(String proxyUser, String proxyPassword) {
this.proxyUser = proxyUser;
this.proxyPassword = proxyPassword;
}
@Override
public Request authenticateProxy(Proxy proxy, Response response) throws IOException {
return authenticate(proxy, response);
}
@Override
public Request authenticate(Proxy proxy, Response response) throws IOException {
String credential = Credentials.basic(proxyUser, proxyPassword);
return response.request().newBuilder()
.header("Proxy-Authorization", credential)
.build();
}
}
我通过 com.squareup.okhttp 得到了这个异常:
java.net.ProtocolException: 后续请求太多:21
【问题讨论】:
标签: java http authentication proxy okhttp