首页 > 解决方案 > 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/&amp;q=EgRVjAHRGPGutfEFIhkA8aeDS1HQdWrbrx7jkGSfPgX8M5Ou6VMLMgFy">here</A>.
</BODY></HTML>

我选择作为选项:

Transfer-Encoding: chunked

但我仍然得到 Content-Length: 325,并且所有内容都没有被分块编码。如何使用 telnet 使用分块编码发出 GET 请求?

标签: httpgetchunked

解决方案


1)您不能强制服务器在响应中使用分块编码。

2)在请求上设置“Transfer-Encoding”意味着您使用分块编码发送。


推荐阅读