我正在学习 HTTP 协议。我已选择此站点进行实验:http://www.testingmcafeesites.com/testcat_ac.html
我已经屏蔽了我的防火墙。打开命令提示符并给出以下命令:
telnet testingmcafeesites.com 80
那行得通,然后我给这个:
GET / HTTP/1.1
Host: testingmcafeesites.com
我也试过:
GET / testcat_ac.html HTTP/1.1
Host: testingmcafeesites.com
但这也不起作用。 返回:
HTTP/1.1 400 Bad Request
Content-Type: text/html
Content-Length: 173
Connection: close
<html>
<head><title>400 Bad Request</title></head>
<body bgcolor="white">
<center><h1>400 Bad Request</h1></center>
<hr><center>Avi Vantage/</center>
</body>
</html>
答案 0 :(得分:1)
改为发送:
GET / HTTP/1.1
Host: testingmcafeesites.com
GET /testcat_ac.html HTTP/1.1
Host: testingmcafeesites.com
注意删除了 /
和 testcat_ac.html
之间的空格。以及 Host
标头之后的额外空行。 HTTP 请求被 2 个 CRLF 换行符终止:
GET / HTTP/1.1<CRLF>
Host: testingmcafeesites.com<CRLF>
<CRLF>
GET /testcat_ac.html HTTP/1.1<CRLF>
Host: testingmcafeesites.com<CRLF>
<CRLF>