Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/http/4.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
Http 将响应gzip压缩发送到不';是否指定接受编码:gzip?_Http - Fatal编程技术网

Http 将响应gzip压缩发送到不';是否指定接受编码:gzip?

Http 将响应gzip压缩发送到不';是否指定接受编码:gzip?,http,Http,如果服务器将内容gzip压缩发送到未指定接受编码:gzip的客户端,这是否是服务器中的错误?它是否违反了http规范?还是合法 我很好奇,因为总是发送gzip压缩的内容,不管接受编码头是什么,作为一个简单的测试来确认: $ curl https://www.amazon.com Warning: Binary output can mess up your terminal. Use "--output -" to tell Warning: curl to output it to your

如果服务器将内容gzip压缩发送到未指定
接受编码:gzip
的客户端,这是否是服务器中的错误?它是否违反了http规范?还是合法

我很好奇,因为总是发送gzip压缩的内容,不管接受编码头是什么,作为一个简单的测试来确认:

$ curl https://www.amazon.com
Warning: Binary output can mess up your terminal. Use "--output -" to tell
Warning: curl to output it to your terminal anyway, or consider "--output
Warning: <FILE>" to save to a file.

$ curl https://www.amazon.com -I
HTTP/2 405
content-type: text/html; charset=UTF-8
server: Server
date: Sat, 03 Nov 2018 11:27:35 GMT
set-cookie: skin=noskin; path=/; domain=.amazon.com
strict-transport-security: max-age=47474747; includeSubDomains; preload
x-amz-id-1: 2M3HZHHA9J21D3MTHH4K
allow: POST, GET
vary: Accept-Encoding,User-Agent,X-Amazon-CDN-Cache
content-encoding: gzip
x-amz-rid: 2M3HZHHA9J21D3MTHH4K
x-frame-options: SAMEORIGIN
x-cache: Error from cloudfront
via: 1.1 1cc4305a3ce000ca199328864ca1c98e.cloudfront.net (CloudFront)
x-amz-cf-id: OKz61IdKmCBfC97pPg-zmDhQnJzK3THXL2iYwegU5EtDaRf6yjBGzw==
$curlhttps://www.amazon.com
警告:二进制输出可能会弄乱终端。使用“-output-”来说明
警告:卷曲输出到你的终端,或考虑“-输出”
警告:“保存到文件。
$curlhttps://www.amazon.com -我
HTTP/2405
内容类型:text/html;字符集=UTF-8
服务器:服务器
日期:2018年11月3日星期六11:27:35 GMT
设置cookie:skin=noskin;路径=/;域名=.amazon.com
严格的交通安全:最大年龄=4747岁;包括子域;预载
x-amz-id-1:2M3HZHHA9J21D3MTH4K
允许:发布,获取
变化:接受编码、用户代理、X-Amazon-CDN-Cache
内容编码:gzip
x-amz-rid:2M3HZHHA9J21D3MTH4K
x-frame-options:SAMEORIGIN
x-cache:来自cloudfront的错误
via:1.1 1cc4305a3ce000ca199328864ca1c98e.cloudfront.net(cloudfront)
x-amz-cf-id:OKz61IdKmCBfC97pPg-ZMDHQNJZK3THXL2YWEG5ETDARF6YJBGZW==
  • curl抱怨它在这里接收二进制数据,因为它没有用HTML响应,而是用gzip压缩的HTML响应,这是二进制数据。要实际查看html,请添加
    --compressed
    参数,该参数告诉curl添加标题
    接受编码:gzip,放气
    并自动解压缩响应
没有Accept Encoding标头字段的请求意味着用户代理没有关于内容编码的首选项。尽管这允许服务器在响应中使用任何内容编码,但并不意味着用户代理将能够正确处理所有编码

--

没有Accept Encoding标头字段的请求意味着用户代理没有关于内容编码的首选项。尽管这允许服务器在响应中使用任何内容编码,但并不意味着用户代理将能够正确处理所有编码


--

猜测这意味着
no
,规范允许这种行为^^^同一文档还声明
一个“标识”标记被用作“无编码”的同义词
——事实上,
curl-H“接受编码:标识”https://www.amazon.com
从amazon.com关闭压缩,这意味着
,规范允许这种行为^^同一文档还声明
将“标识”标记用作“无编码”的同义词
——事实上,
curl-H“接受编码:标识”https://www.amazon.com
关闭amazon.com的压缩功能