- 在command line中输入ncat -l 9999, 本地开一个服务器监听9999端口
- 在浏览器中输入localhost:9999
- 此时命令行中出现
GET / HTTP/1.1 Host: localhost:8989 Connection: keep-alive Cache-Control: max-age=0 Upgrade-Insecure-Requests: 1 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.139 Safari/537.36 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8 Accept-Encoding: gzip, deflate, br Accept-Language: zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7
- 此时在命令行中可以输入response
HTTP/1.1 200 OK Content-type: text/html; charset=UTF-8 Contetn-length: 79//此行可不写,那么浏览器将可以永久保持连接
- 敲回车空一行,再输入任何内容都将出现在浏览器上(字节数不能超过Content-length)
- 还可以
HTTP/1.1 301 Moved Permanently Location: https://www.baidu.com
HTTP 小练习
最新推荐文章于 2023-03-21 09:38:55 发布