我想要理解HTTP和头部信息,所以我在尝试使用Telnet发送请求。为了不用一遍又一遍地输入相同的内容,我决定写一个包含我需要的所有命令的小文本文件。
我的文本文件非常简单,内容如下:
GET /somefile.php HTTP/1.1
Host: localhost
然后我尝试使用io重定向将其提供给telnet:
$ telnet localhost 80 < telnet.txt
但我得到的所有输出都是
Trying ::1...
Connected to localhost.
Escape character is '^]'.
Connection closed by foreign host.
我做错了什么?