跳到主要内容

5. 示例 (Examples)

5.1. 请求示例 (Request Example)

一个简单的 GET 请求:

GET /hello.txt HTTP/1.1
Host: www.example.com

会被编码为 known-length binary message, 其中:

  • Framing Indicator = 0 (known-length request)
  • Method = "GET"
  • Scheme = "https"
  • Authority = "www.example.com"
  • Path = "/hello.txt"
  • Header section 带有 "host" field
  • Empty content (length = 0)
  • Empty trailer section (length = 0)

5.2. 响应示例 (Response Example)

一个简单的 200 OK 响应:

HTTP/1.1 200 OK
Content-Type: text/plain
Content-Length: 12

Hello World!

会被编码为:

  • Framing Indicator = 1 (known-length response)
  • Status Code = 200
  • Header section 带有 "content-type" 和 "content-length" fields
  • Content = "Hello World!" (12 bytes)
  • Empty trailer section (length = 0)