mirror of
https://github.com/square/okhttp.git
synced 2025-11-26 06:43:09 +03:00
Make the nested BasicAuthInterceptor static (#4368)
This commit is contained in:
committed by
Yuri Schimke
parent
0a8f418644
commit
bcbbfc6a54
@@ -15,15 +15,14 @@
|
|||||||
*/
|
*/
|
||||||
package okhttp3.recipes;
|
package okhttp3.recipes;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import okhttp3.Credentials;
|
import okhttp3.Credentials;
|
||||||
import okhttp3.Interceptor;
|
import okhttp3.Interceptor;
|
||||||
import okhttp3.OkHttpClient;
|
import okhttp3.OkHttpClient;
|
||||||
import okhttp3.Request;
|
import okhttp3.Request;
|
||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
|
|
||||||
import java.io.IOException;
|
public final class PreemptiveAuth {
|
||||||
|
|
||||||
public class PreemptiveAuth {
|
|
||||||
private final OkHttpClient client;
|
private final OkHttpClient client;
|
||||||
|
|
||||||
public PreemptiveAuth() {
|
public PreemptiveAuth() {
|
||||||
@@ -49,7 +48,7 @@ public class PreemptiveAuth {
|
|||||||
new PreemptiveAuth().run();
|
new PreemptiveAuth().run();
|
||||||
}
|
}
|
||||||
|
|
||||||
class BasicAuthInterceptor implements Interceptor {
|
static final class BasicAuthInterceptor implements Interceptor {
|
||||||
private final String credentials;
|
private final String credentials;
|
||||||
private final String host;
|
private final String host;
|
||||||
|
|
||||||
@@ -58,8 +57,7 @@ public class PreemptiveAuth {
|
|||||||
this.host = host;
|
this.host = host;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override public Response intercept(Chain chain) throws IOException {
|
||||||
public Response intercept(Chain chain) throws IOException {
|
|
||||||
Request request = chain.request();
|
Request request = chain.request();
|
||||||
if (request.url().host().equals(host)) {
|
if (request.url().host().equals(host)) {
|
||||||
request = request.newBuilder()
|
request = request.newBuilder()
|
||||||
@@ -69,5 +67,4 @@ public class PreemptiveAuth {
|
|||||||
return chain.proceed(request);
|
return chain.proceed(request);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user