okhttp3 Response 拦截器

135 阅读1分钟
import java.io.IOException;

import okhttp3.Interceptor;
import okhttp3.Response;

public class ResponseInterceptor implements Interceptor {
  @Override
  public Response intercept(Chain chain) throws IOException {
    Response response = chain.proceed(chain.request());
    int code = response.code();
    if (code != 200) {
      throw new ErrorException(code, response.body().string());
    }
    return response;
  }
}