mirror of
https://github.com/VibedByKaKi/alexandroid.git
synced 2026-11-19 04:13:18 +01:00
42 lines
1.4 KiB
Java
42 lines
1.4 KiB
Java
package org.apache.http.protocol;
|
|
|
|
import java.io.IOException;
|
|
import org.apache.http.HttpException;
|
|
import org.apache.http.HttpRequest;
|
|
import org.apache.http.HttpRequestInterceptor;
|
|
import org.apache.http.annotation.Contract;
|
|
import org.apache.http.annotation.ThreadingBehavior;
|
|
import org.apache.http.params.CoreProtocolPNames;
|
|
import org.apache.http.params.HttpParams;
|
|
import org.apache.http.util.Args;
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
@Contract(threading = ThreadingBehavior.IMMUTABLE)
|
|
/* loaded from: classes11.dex */
|
|
public class RequestUserAgent implements HttpRequestInterceptor {
|
|
private final String userAgent;
|
|
|
|
public RequestUserAgent(String str) {
|
|
this.userAgent = str;
|
|
}
|
|
|
|
@Override // org.apache.http.HttpRequestInterceptor
|
|
public void process(HttpRequest httpRequest, HttpContext httpContext) throws HttpException, IOException {
|
|
Args.notNull(httpRequest, "HTTP request");
|
|
if (httpRequest.containsHeader("User-Agent")) {
|
|
return;
|
|
}
|
|
HttpParams params = httpRequest.getParams();
|
|
String str = params != null ? (String) params.getParameter(CoreProtocolPNames.USER_AGENT) : null;
|
|
if (str == null) {
|
|
str = this.userAgent;
|
|
}
|
|
if (str != null) {
|
|
httpRequest.addHeader("User-Agent", str);
|
|
}
|
|
}
|
|
|
|
public RequestUserAgent() {
|
|
this(null);
|
|
}
|
|
}
|