Perfume Of Love v2.14.9版本的 MD5 值为:16011aefc5a55805771706ce3b259b4e
以下内容为反编译后的 Response.java 源代码,内容仅作参考
package com.vungle.warren.network;
import okhttp3.Headers;
import okhttp3.Protocol;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.ResponseBody;
public final class Response<T> {
private final T body;
private final ResponseBody errorBody;
private final okhttp3.Response rawResponse;
public static <T> Response<T> success(T t) {
return success(t, new Response.Builder().code(200).message("OK").protocol(Protocol.HTTP_1_1).request(new Request.Builder().url("http://localhost/").build()).build());
}
public static <T> Response<T> success(T t, okhttp3.Response response) {
if (!response.isSuccessful()) {
throw new IllegalArgumentException("rawResponse must be successful response");
}
return new Response<>(response, t, null);
}
public static <T> Response<T> error(int i, ResponseBody responseBody) {
if (i < 400) {
throw new IllegalArgumentException("code < 400: " + i);
}
return error(responseBody, new Response.Builder().code(i).message("Response.error()").protocol(Protocol.HTTP_1_1).request(new Request.Builder().url("http://localhost/").build()).build());
}
public static <T> Response<T> error(ResponseBody responseBody, okhttp3.Response response) {
if (response.isSuccessful()) {
throw new IllegalArgumentException("rawResponse should not be successful response");
}
return new Response<>(response, null, responseBody);
}
private Response(okhttp3.Response response, T t, ResponseBody responseBody) {
this.rawResponse = response;
this.body = t;
this.errorBody = responseBody;
}
public okhttp3.Response raw() {
return this.rawResponse;
}
public int code() {
return this.rawResponse.code();
}
public String message() {
return this.rawResponse.message();
}
public Headers headers() {
return this.rawResponse.headers();
}
public boolean isSuccessful() {
return this.rawResponse.isSuccessful();
}
public T body() {
return this.body;
}
public ResponseBody errorBody() {
return this.errorBody;
}
public String toString() {
return this.rawResponse.toString();
}
}