app/src/main/java/net/nashlegend/sourcewall/request/RequestObject.java

(开头部分) 6KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

package net.nashlegend.sourcewall.request;

import android.support.annotation.NonNull;
import android.support.annotation.Nullable;

import net.nashlegend.sourcewall.request.parsers.Parser;

import java.util.ArrayList;
import java.util.List;

import okhttp3.CacheControl;
import okhttp3.Headers;
import okhttp3.MediaType;
import okhttp3.RequestBody;

/**
 * Created by NashLegend on 2015/9/23 0023.
 * 网络请求的对象
 */
public class RequestObject<T> {
    /**
     * 默认Tag
     */
    public static final String DefaultTag = "RequestObject";

    public String url = "";
    public String method = Method.GET;
    public Object tag = DefaultTag;
    public RequestBody requestBody;
    public Headers.Builder headers;
    public CacheControl cacheControl;

    public boolean requestWithGzip = false;//是否使用Gzip压缩请求数据
    public String fakeResponse = null;
    public int maxRetryTimes = 0;//最大重试次数
    public int interval = 0;//重试间隔
    public int requestType = RequestType.PLAIN;
    public final List<Param> params = new ArrayList<>();
    public RequestCallBack<T> callBack = null;
    public Parser<T> parser;
    public String uploadFileKey = "file";
    public MediaType mediaType = null;
    public String uploadFilePath = "";
    public String downloadFilePath = "";

    /**
     * 是否优先使用缓存,如果useCachedFirst为true,那么useCachedIfFailed就为false了
     * 仅仅在使用Rx时有效,与useCacheIfFailed互斥
     */
    protected boolean useCachedFirst = false;
    /**
     * 请求失败时是否使用缓存,如果为true,那么将使用缓存,请求成功的话也会将成功的数据缓存下来,
     * 与useCachedFirst互斥
     */
    protected boolean useCachedIfFailed = false;
    /**
     * 缓存时间,如果上次保存的缓存时间与本次请求的时间差相差超过了cacheTimeOut,则重新请求一次
     */
    protected long cacheTimeOut = -1;//如果是-1则表示永不超时
    /*果壳貌似本身并没有Cache-Control,或者Cache-Control的max-age=0 所以这里的缓存是本地缓存*/
后面还有 161 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。