HTTP

TCP建立連接(Three-way handshake)

  1. C --> S 握手請求
  2. C <-- S 確認請求
  3. C --> S 數(shù)據(jù)請求
  4. C <-- S 發(fā)送數(shù)據(jù)

Non-Persistent Connections

  • 一次數(shù)據(jù)發(fā)送完成后就關閉TCP連接

HTTP with Persistent Connections

  • 發(fā)送多次數(shù)據(jù)后再關閉TCP連接
  • 降低延遲但是占用服務器端網(wǎng)絡資源
  • 一般情況下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>
最后編輯于
?著作權歸作者所有,轉載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容