Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/324.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/jenkins/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java GZIP与httpclient 4.5.3_Java_Gzip_Apache Httpclient 4.x_Apache Fluent Api - Fatal编程技术网

Java GZIP与httpclient 4.5.3

Java GZIP与httpclient 4.5.3,java,gzip,apache-httpclient-4.x,apache-fluent-api,Java,Gzip,Apache Httpclient 4.x,Apache Fluent Api,我正在使用httpclient 4.5.3和Fluent API()。从4.2.x升级到httpclient 4.5.3后,响应中的“Content Encoding”头似乎从响应头中删除,我不知道如何支持gzip压缩 我正在向发送GET请求并发送标题“接受编码”:“gzip” 我在4.5.3中的响应标题现在显示以下内容,但没有内容编码标题: Date: Thu, 01 Jun 2017 21:21:55 GMT Strict-Transport-Security: max-age=259200

我正在使用httpclient 4.5.3和Fluent API()。从4.2.x升级到httpclient 4.5.3后,响应中的“Content Encoding”头似乎从响应头中删除,我不知道如何支持gzip压缩

我正在向发送GET请求并发送标题“接受编码”:“gzip”

我在4.5.3中的响应标题现在显示以下内容,但没有内容编码标题:

Date: Thu, 01 Jun 2017 21:21:55 GMT
Strict-Transport-Security: max-age=2592000
X-Frame-Options: DENY
Set-Cookie: autorf=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; Max-Age=0; path=/; domain=www.yahoo.com
Vary: Accept-Encoding
Content-Type: text/html; charset=UTF-8
Age: 0
Transfer-Encoding: chunked
Connection: keep-alive
Via: http/1.1 ir11.fp.ne1.yahoo.com (ApacheTrafficServer)
Server: ATS
Cache-Control: no-store, no-cache, private, max-age=0
Expires: -1
我的响应处理程序有以下代码。但是,entity.getContentEncoding()始终为空

 HttpEntity entity = response.getEntity();
            Header header = entity.getContentEncoding();
            if (header == null) {
                return EntityUtils.toString(entity);
            } else {
                return handleGzipStream(entity);
            }
在调试器中运行时,wrappedEntity的标题中似乎没有内容编码:gzip。我如何访问它?或者,使用httpclient 4.5.3处理gzip压缩的正确方法是什么

删除内容元数据头,例如
内容长度
内容编码
content-MD5
,以确保客户端透明地解压缩的内容流与响应消息头中嵌入的元数据相匹配。这是故意的。如果您想使用fluent facade手动处理内容解压缩,则需要创建自定义请求执行器

Executor executor = Executor.newInstance(HttpClients.custom().disableContentCompression().build());
删除内容元数据头,例如
content Length
content Encoding
content-MD5
,以确保客户端透明地解压缩的内容流与响应消息头中嵌入的元数据相匹配。这是故意的。如果您想使用fluent facade手动处理内容解压缩,则需要创建自定义请求执行器

Executor executor = Executor.newInstance(HttpClients.custom().disableContentCompression().build());