Android Okhttp 隐藏内容编码:gzip 在 header
Android Okhttp hides content encoding : gzip in the header
从 okhttp 的官方文档中可以看出它处理了透明的 gzip 过程。但我的疑问是我的 header 我看不到内容 header,我尝试从它给出的响应中检索 header content-encoding
为空。但我没有添加任何额外的 header 进行编码。
我通过 RestClient
尝试了相同的请求,从中我可以看到 header content-encoding: gzip
fun getOkHttpClient(myInterceptor: MyInterceptor): OkHttpClient {
val okHttpClientBuilder = OkHttpClient.Builder()
.connectTimeout(10, TimeUnit.SECONDS)
.readTimeout(60, TimeUnit.SECONDS)
.writeTimeout(60, TimeUnit.SECONDS)
.addInterceptor(myInterceptor)
return okHttpClientBuilder.build()
}
谁能告诉我可能是什么问题?
这是一个特点:
If transparent compression was used, OkHttp will drop the corresponding response headers Content-Encoding
and Content-Length
because they don’t apply to the decompressed response body.
从 okhttp 的官方文档中可以看出它处理了透明的 gzip 过程。但我的疑问是我的 header 我看不到内容 header,我尝试从它给出的响应中检索 header content-encoding
为空。但我没有添加任何额外的 header 进行编码。
我通过 RestClient
尝试了相同的请求,从中我可以看到 header content-encoding: gzip
fun getOkHttpClient(myInterceptor: MyInterceptor): OkHttpClient {
val okHttpClientBuilder = OkHttpClient.Builder()
.connectTimeout(10, TimeUnit.SECONDS)
.readTimeout(60, TimeUnit.SECONDS)
.writeTimeout(60, TimeUnit.SECONDS)
.addInterceptor(myInterceptor)
return okHttpClientBuilder.build()
}
谁能告诉我可能是什么问题?
这是一个特点:
If transparent compression was used, OkHttp will drop the corresponding response headers
Content-Encoding
andContent-Length
because they don’t apply to the decompressed response body.