Java Code Examples for com.lzy.okgo.model.Response#code()

The following examples show how to use com.lzy.okgo.model.Response#code() . 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: DefaultCachePolicy.java    From okhttp-OkGo with Apache License 2.0 6 votes vote down vote up
@Override
public Response<T> requestSync(CacheEntity<T> cacheEntity) {
    try {
        prepareRawCall();
    } catch (Throwable throwable) {
        return Response.error(false, rawCall, null, throwable);
    }
    Response<T> response = requestNetworkSync();
    //HTTP cache protocol
    if (response.isSuccessful() && response.code() == 304) {
        if (cacheEntity == null) {
            response = Response.error(true, rawCall, response.getRawResponse(), CacheException.NON_AND_304(request.getCacheKey()));
        } else {
            response = Response.success(true, cacheEntity.getData(), rawCall, response.getRawResponse());
        }
    }
    return response;
}
 
Example 2
Source File: DefaultCachePolicy.java    From BaseProject with Apache License 2.0 6 votes vote down vote up
@Override
public Response<T> requestSync(CacheEntity<T> cacheEntity) {
    try {
        prepareRawCall();
    } catch (Throwable throwable) {
        return Response.error(false, rawCall, null, throwable);
    }
    Response<T> response = requestNetworkSync();
    //HTTP cache protocol
    if (response.isSuccessful() && response.code() == 304) {
        if (cacheEntity == null) {
            response = Response.error(true, rawCall, response.getRawResponse(), CacheException.NON_AND_304(request.getCacheKey()));
        } else {
            response = Response.success(true, cacheEntity.getData(), rawCall, response.getRawResponse());
        }
    }
    return response;
}
 
Example 3
Source File: HttpException.java    From okhttp-OkGo with Apache License 2.0 4 votes vote down vote up
public HttpException(Response<?> response) {
    super(getMessage(response));
    this.code = response.code();
    this.message = response.message();
    this.response = response;
}
 
Example 4
Source File: HttpException.java    From okhttp-OkGo with Apache License 2.0 4 votes vote down vote up
private static String getMessage(Response<?> response) {
    HttpUtils.checkNotNull(response, "response == null");
    return "HTTP " + response.code() + " " + response.message();
}
 
Example 5
Source File: HttpException.java    From BaseProject with Apache License 2.0 4 votes vote down vote up
public HttpException(Response<?> response) {
    super(getMessage(response));
    this.code = response.code();
    this.message = response.message();
    this.response = response;
}
 
Example 6
Source File: HttpException.java    From BaseProject with Apache License 2.0 4 votes vote down vote up
private static String getMessage(Response<?> response) {
    HttpUtils.checkNotNull(response, "response == null");
    return "HTTP " + response.code() + " " + response.message();
}