Java Code Examples for com.lzy.okgo.OkGo#getCommonHeaders()

The following examples show how to use com.lzy.okgo.OkGo#getCommonHeaders() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Request.java    From okhttp-OkGo with Apache License 2.0 6 votes vote down vote up
public Request(String url) {
    this.url = url;
    baseUrl = url;
    OkGo go = OkGo.getInstance();
    //默认添加 Accept-Language
    String acceptLanguage = HttpHeaders.getAcceptLanguage();
    if (!TextUtils.isEmpty(acceptLanguage)) headers(HttpHeaders.HEAD_KEY_ACCEPT_LANGUAGE, acceptLanguage);
    //默认添加 User-Agent
    String userAgent = HttpHeaders.getUserAgent();
    if (!TextUtils.isEmpty(userAgent)) headers(HttpHeaders.HEAD_KEY_USER_AGENT, userAgent);
    //添加公共请求参数
    if (go.getCommonParams() != null) params(go.getCommonParams());
    if (go.getCommonHeaders() != null) headers(go.getCommonHeaders());
    //添加缓存模式
    retryCount = go.getRetryCount();
    cacheMode = go.getCacheMode();
    cacheTime = go.getCacheTime();
}
 
Example 2
Source File: Request.java    From BaseProject with Apache License 2.0 6 votes vote down vote up
public Request(String url) {
    this.url = url;
    baseUrl = url;
    OkGo go = OkGo.getInstance();
    //默认添加 Accept-Language
    String acceptLanguage = HttpHeaders.getAcceptLanguage();
    if (!TextUtils.isEmpty(acceptLanguage)) headers(HttpHeaders.HEAD_KEY_ACCEPT_LANGUAGE, acceptLanguage);
    //默认添加 User-Agent
    String userAgent = HttpHeaders.getUserAgent();
    if (!TextUtils.isEmpty(userAgent)) headers(HttpHeaders.HEAD_KEY_USER_AGENT, userAgent);
    //添加公共请求参数
    if (go.getCommonParams() != null) params(go.getCommonParams());
    if (go.getCommonHeaders() != null) headers(go.getCommonHeaders());
    //添加缓存模式
    retryCount = go.getRetryCount();
    cacheMode = go.getCacheMode();
    cacheTime = go.getCacheTime();
}