请求报文

请求方法(GET,POST等) 空格  URL 空格 协议版本\r\n
字段名: 字段值\r\n
...
字段名: 字段值\r\n
\r\n
请求体的内容

比如:

GET /2017/06/02/Golang-%E6%B1%87%E7%BC%96%E6%9D%82%E9%A1%B9/ HTTP/1.1
Host: emacsist.github.io
Connection: keep-alive
Pragma: no-cache
Cache-Control: no-cache
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Referer: https://emacsist.github.io/tags/golang/

响应报文

协议及版本 空格 状态码 空格 描述\r\n
字段: 字段值\r\n
...
字段: 字段值\r\n
\r\n
响应体的内容

比如:

HTTP/1.1 200 OK
Server: GitHub.com
Content-Type: text/html; charset=utf-8
Last-Modified: Fri, 16 Jun 2017 13:44:31 GMT
Access-Control-Allow-Origin: *
Expires: Thu, 22 Jun 2017 07:41:06 GMT
Cache-Control: max-age=600
Content-Encoding: gzip
X-GitHub-Request-Id: F682:28F28:E2E8C4:F13E12:594B7239
Content-Length: 6688
Accept-Ranges: bytes
Date: Thu, 22 Jun 2017 07:31:06 GMT
Via: 1.1 varnish
Age: 0
Connection: keep-alive
X-Served-By: cache-nrt6120-NRT
X-Cache: MISS
X-Cache-Hits: 0
X-Timer: S1498116666.909413,VS0,VE213
Vary: Accept-Encoding
X-Fastly-Request-ID: aadc9ce160db1f0a3d9b123dede2dcc2e311b549

HTTP1.1 协议规范

http rfc2616