HTTP Protocol

Review

  1. 2024-09-26 22:09

[!Summary] HTTP https://developer.mozilla.org/zh-CN/docs/Web/HTTP 超文本传输协议(HTTP)是一个用于传输超媒体文档(例如 HTML)的应用层协议。它是为 Web 浏览器与 Web 服务器之间的通信而设计的,但也可以用于其他目的。HTTP 遵循经典的客户端—服务端模型,客户端打开一个连接以发出请求,然后等待直到收到服务器端响应。HTTP 是无状态协议,这意味着服务器不会在两个请求之间保留任何数据(状态)。

HTTP is defined by these  IETF RFCs and  IANA registries. The  IETF HTTP Working Group maintains and develops the Hypertext Transfer Protocol - the core protocol of the World Wide Web.

[!Summary] 书籍推荐📚

  1. 《图解HTTP》2014
  2. 《HTTP权威指南》2012
  3. 《TCP/IP详解》卷1:协议 2016
  4. 《HTTP/2 in Action》
  5. 《HTTPS权威指南》
  6. 《解析QUIC/HTTP3:未来互联网的基石》2024/07

在线学习平台

  1. MDN HTTP
  2. HTTP Documentation
  3. HTTP Extensions
  4. RFC https://datatracker.ietf.org/
  5. HTTP-WG https://httpwg.org/

必读资料

  1. How browsers work

[!Warning] Core Specifications

The “core” semantics of the HTTP protocol are defined by:

Those semantics are expressed “on the wire” in three ways:

Later versions of HTTP offer field compression:

These RFCs collectively obsolete all preceding RFCs defining HTTP, including RFC 1945RFC 2068RFC 2616RFC 2617RFC 7230-5, and RFC 7540.

一、Introduction #

Message Format #
HTTP-message   = start-line CRLF
			   *( field-line CRLF )
			   CRLF
			   [ message-body ]

start-line = request-line / status-line

请求 #
请求行
消息头

消息体
响应 #
状态行
消息头

消息体

准确来说,响应消息体的格式会通过响应的消息头中的 Content-Type 字段来定义(MIME类型)。

Web服务器 #
  1. Nginx
  2. Apache/ApacheHTTPD
  3. Apache Traffic Server
  4. LiteSpeed
  5. H2O
  6. IIS
  7. nghttpd
  8. NodeJS
  9. Shimmercat
  10. CaddyServer
  11. HAProxy
  12. HS
  13. AWS ELB
  14. LiteSpeed
查看HTTP请求的工具 #
  1. curl
  2. wget
  3. httpie
  4. nc (netcat)
  5. Wireshark
  6. Fiddler
  7. Chrome net-internals chrome://net-export/ chrome://net-internals/ https://netlog-viewer.appspot.com/
  8. Advanced REST Client
  9. Postman
  10. Rested
  11. RESTClient
  12. RESTMan
  13. nghttp 基于 Firefox 实现

Reference #