Spermatid v6.1.8版本的 MD5 值为:a375ce51a42d528ba6e2583c10478296
以下内容为反编译后的 UrlRequestBuilderImpl.java 源代码,内容仅作参考
package aegon.chrome.net.impl;
import aegon.chrome.net.ExperimentalUrlRequest;
import aegon.chrome.net.RequestFinishedInfo;
import aegon.chrome.net.UploadDataProvider;
import aegon.chrome.net.UrlRequest;
import android.util.Log;
import android.util.Pair;
import com.baidu.mobads.sdk.internal.an;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.Objects;
import java.util.concurrent.Executor;
public class UrlRequestBuilderImpl extends ExperimentalUrlRequest.Builder {
private static final String ACCEPT_ENCODING = "Accept-Encoding";
private static final String TAG = "UrlRequestBuilderImpl";
private boolean mAllowDirectExecutor;
private final UrlRequest.Callback mCallback;
private final CronetEngineBase mCronetEngine;
private boolean mDisableCache;
private boolean mDisableConnectionMigration;
private final Executor mExecutor;
private String mMethod;
private Collection<Object> mRequestAnnotations;
private RequestFinishedInfo.Listener mRequestFinishedListener;
private int mTrafficStatsTag;
private boolean mTrafficStatsTagSet;
private int mTrafficStatsUid;
private boolean mTrafficStatsUidSet;
private UploadDataProvider mUploadDataProvider;
private Executor mUploadDataProviderExecutor;
private final String mUrl;
private final ArrayList<Pair<String, String>> mRequestHeaders = new ArrayList<>();
private int mPriority = 3;
public UrlRequestBuilderImpl(String str, UrlRequest.Callback callback, Executor executor, CronetEngineBase cronetEngineBase) {
Objects.requireNonNull(str, "URL is required.");
Objects.requireNonNull(callback, "Callback is required.");
Objects.requireNonNull(executor, "Executor is required.");
Objects.requireNonNull(cronetEngineBase, "CronetEngine is required.");
this.mUrl = str;
this.mCallback = callback;
this.mExecutor = executor;
this.mCronetEngine = cronetEngineBase;
}
@Override
public UrlRequestBuilderImpl addRequestAnnotation(Object obj) {
Objects.requireNonNull(obj, "Invalid metrics annotation.");
if (this.mRequestAnnotations == null) {
this.mRequestAnnotations = new ArrayList();
}
this.mRequestAnnotations.add(obj);
return this;
}
@Override
public UrlRequestBuilderImpl disableConnectionMigration() {
this.mDisableConnectionMigration = true;
return this;
}
@Override
public ExperimentalUrlRequest.Builder setHttpMethod(String str) {
Objects.requireNonNull(str, "Method is required.");
this.mMethod = str;
return this;
}
@Override
public UrlRequestBuilderImpl setRequestFinishedListener(RequestFinishedInfo.Listener listener) {
this.mRequestFinishedListener = listener;
return this;
}
@Override
public UrlRequestBuilderImpl setTrafficStatsTag(int i10) {
this.mTrafficStatsTagSet = true;
this.mTrafficStatsTag = i10;
return this;
}
@Override
public UrlRequestBuilderImpl setTrafficStatsUid(int i10) {
this.mTrafficStatsUidSet = true;
this.mTrafficStatsUid = i10;
return this;
}
@Override
public UrlRequestBuilderImpl addHeader(String str, String str2) {
Objects.requireNonNull(str, "Invalid header name.");
Objects.requireNonNull(str2, "Invalid header value.");
if ("Accept-Encoding".equalsIgnoreCase(str)) {
Log.w(TAG, "It's not necessary to set Accept-Encoding on requests - cronet will do this automatically for you, and setting it yourself has no effect. See https://crbug.com/581399 for details.", new Exception());
return this;
}
this.mRequestHeaders.add(Pair.create(str, str2));
return this;
}
@Override
public UrlRequestBuilderImpl allowDirectExecutor() {
this.mAllowDirectExecutor = true;
return this;
}
@Override
public UrlRequestBase build() {
UrlRequestBase createRequest = this.mCronetEngine.createRequest(this.mUrl, this.mCallback, this.mExecutor, this.mPriority, this.mRequestAnnotations, this.mDisableCache, this.mDisableConnectionMigration, this.mAllowDirectExecutor, this.mTrafficStatsTagSet, this.mTrafficStatsTag, this.mTrafficStatsUidSet, this.mTrafficStatsUid, this.mRequestFinishedListener);
String str = this.mMethod;
if (str != null) {
createRequest.setHttpMethod(str);
}
Iterator<Pair<String, String>> it = this.mRequestHeaders.iterator();
while (it.hasNext()) {
Pair<String, String> next = it.next();
createRequest.addHeader((String) next.first, (String) next.second);
}
UploadDataProvider uploadDataProvider = this.mUploadDataProvider;
if (uploadDataProvider != null) {
createRequest.setUploadDataProvider(uploadDataProvider, this.mUploadDataProviderExecutor);
}
return createRequest;
}
@Override
public UrlRequestBuilderImpl disableCache() {
this.mDisableCache = true;
return this;
}
@Override
public UrlRequestBuilderImpl setPriority(int i10) {
this.mPriority = i10;
return this;
}
@Override
public UrlRequestBuilderImpl setUploadDataProvider(UploadDataProvider uploadDataProvider, Executor executor) {
Objects.requireNonNull(uploadDataProvider, "Invalid UploadDataProvider.");
Objects.requireNonNull(executor, "Invalid UploadDataProvider Executor.");
if (this.mMethod == null) {
this.mMethod = an.f4374b;
}
this.mUploadDataProvider = uploadDataProvider;
this.mUploadDataProviderExecutor = executor;
return this;
}
}