HTTP

TCP建立连接(Three-way handshake)

  1. C --> S 握手请求
  2. C <-- S 确认请求
  3. C --> S 数据请求
  4. 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>
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容