CronetInterceptor

public final class CronetInterceptor implements Interceptor, AutoCloseable


一种 OkHttp 拦截器,用于重定向 HTTP 流量以使用 Cronet,而不是使用 OkHttp 网络堆栈。

拦截器应作为最后一个应用拦截器使用,以确保在通过网络发送请求之前和返回响应之后访问所有其他拦截器。

拦截器在很大程度上是 OkHttp 堆栈的即插即用替代品,不过,需要注意以下几点:

  1. 整个 OkHttp 核心都被绕过。这包括缓存配置和网络拦截器。
  2. 由于 Cronet 和 OkHttp 的架构不匹配,部分响应字段未填充。TODO(danstahr):添加具体列表)。

摘要

嵌套类型

public final class CronetInterceptor.Builder

CronetInterceptor 的构建器。

公共方法

void
Response
static CronetInterceptor.Builder
newBuilder(CronetEngine cronetEngine)

创建 CronetInterceptor 构建器。

继承的常量

来自 okhttp3.Interceptor

公共方法

关闭

public void close()

intercept

public Response intercept(Interceptor.Chain chain)

newBuilder

public static CronetInterceptor.Builder newBuilder(CronetEngine cronetEngine)

创建 CronetInterceptor 构建器。