http - Linux 上的 Telnet - 我可以将 Transfer-encoding: chunked 设置为 GET 选项吗?
问题描述
我想从服务器获得分块响应,但我不明白 - 我在这个终端日志中做错了什么:
telnet www.google.com 80
Trying 172.217.20.36...
Connected to www.google.com.
Escape character is '^]'.
GET / HTTP/1.1
Transfer-Encoding: chunked
HTTP/1.1 302 Found
Location: http://www.google.com/sorry/index?continue=http://www.google.com/&q=EgRVjAHRGPGutfEFIhkA8aeDS1HQdWrbrx7jkGSfPgX8M5Ou6VMLMgFy
Date: Sun, 26 Jan 2020 09:10:10 GMT
Pragma: no-cache
Expires: Fri, 01 Jan 1990 00:00:00 GMT
Cache-Control: no-store, no-cache, must-revalidate
Content-Type: text/html; charset=UTF-8
Server: HTTP server (unknown)
Content-Length: 325
X-XSS-Protection: 0
Connection: close
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>302 Moved</TITLE></HEAD><BODY>
<H1>302 Moved</H1>
The document has moved
<A HREF="http://www.google.com/sorry/index?continue=http://www.google.com/&q=EgRVjAHRGPGutfEFIhkA8aeDS1HQdWrbrx7jkGSfPgX8M5Ou6VMLMgFy">here</A>.
</BODY></HTML>
我选择作为选项:
Transfer-Encoding: chunked
但我仍然得到 Content-Length: 325,并且所有内容都没有被分块编码。如何使用 telnet 使用分块编码发出 GET 请求?
解决方案
1)您不能强制服务器在响应中使用分块编码。
2)在请求上设置“Transfer-Encoding”意味着您使用分块编码发送。
推荐阅读
- redis - ZRANGEBYLEX 查询对于相同数量的字符数返回不同的结果
- codeigniter - 使用codeigniter和mysql在单个表中显示付款和收据记录
- javascript - 在包含 NaN 值的对象数组中查找最大值
- react-native - 抽屉菜单标题的高度是多少
- c# - 无法将类型“System.Linq.IQueryable”隐式转换为“Microsoft.EntityFrameworkCore.Query.IIncludableQueryable”
- android - 如何通过 Smart-Linkify(又名“智能文本选择”)将我的应用程序的操作提供给其他应用程序?
- python - 如何从python中的文本文件中复制位于特定位置的变量字符串?
- ruby-on-rails - 在 Rails 5 中将 Formdata 转换为 jpeg 文件
- android - 与 Android(客户端)和 Node.js(服务器)的异步通信
- react-native - 离线运行开发中的Expo