HTTP
2016-11-28 本文已影响0人
crf1028
TCP建立连接(Three-way handshake)
- C --> S 握手请求
- C <-- S 确认请求
- C --> S 数据请求
- C <-- S 发送数据
Non-Persistent Connections
- 一次数据发送完成后就关闭TCP连接
HTTP with Persistent Connections
- 发送多次数据后再关闭TCP连接
- 降低延迟但是占用服务器端网络资源
- 一般情况下HTTP服务器会将已闲置一段时间的TCP连接关闭
HTTP request message example
GET /hello.htm HTTP/1.1
User-Agent: Mozilla/4.0 (compatible; MSIE5.01; Windows NT)
Host: www.tutorialspoint.com
Accept-Language: en-us
Accept-Encoding: gzip, deflate
Connection: Keep-Alive
- 其他请求方法包括GET, POST, HEAD, PUT, and DELETE
HTTP server respond message example
HTTP/1.1 200 OK
Date: Mon, 27 Jul 2009 12:28:53 GMT
Server: Apache/2.2.14 (Win32)
Last-Modified: Wed, 22 Jul 2009 19:15:56 GMT
Content-Length: 88
Content-Type: text/html
Connection: Closed
<html> <body> <h1>Hello, World!</h1> </body></html>