HTTP协议

HTTP

Hello, World.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
rm -rf index.html
touch index.html

body="<h1>Hello, World.</h1>"

echo -e "HTTP/1.1 200 OK\r\n" >> index.html
echo -e "content-type: text/html; charset=utf-8\r\n" >> index.html
echo -e "content-length: ${#body}\r\n" >> index.html
echo -e "connection: close\r\n" >> index.html
echo -e "\r\n" >> index.html

echo "${body}" >> index.html

sudo nc -l 80 < index.html

访问http://127.0.0.1

HTTP/1.1

keep-alive

Content-Length

Transfer-Encoding

HTTP 分块传输编码

本站采用「署名 4.0 国际」进行许可。