请求报文包含三部分:
响应报文包含三部分:
HTTP请求报文格式:
- <Method> <Request-URI> <HTTP-Version>
- <headers>
-
- <entity-body>
-
其中:
示例:
- GET /index.html HTTP/1.1
- Host: www.example.com
- User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:54.0) Gecko/20100101 Firefox/54.0
- Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
- Accept-Language: en-US,en;q=0.5
- Accept-Encoding: gzip, deflate
- Connection: keep-alive
- Upgrade-Insecure-Requests: 1
-
HTTP响应报文格式:
- <HTTP-Version> <Status-Code> <Reason-Phrase>
- <headers>
-
- <entity-body>
-
其中:
示例:
- HTTP/1.1 200 OK
- Date: Wed, 21 Oct 2015 07:28:00 GMT
- Content-Type: text/html; charset=utf-8
- Content-Length: 35739
- Last-Modified: Mon, 19 Oct 2015 12:48:36 GMT
- Connection: keep-alive
- ETag: "5625f0d0-8b23"
- Access-Control-Allow-Origin: *
- Cache-Control: max-age=86400
- Expires: Thu, 22 Oct 2015 07:28:00 GMT
-
- <!doctype html>
- <html>
- <head>
- <title>Example Domain</title>
- ... ...
- </body>
- </html>