在 HTTP header 中发送数据并取回

Send data in an HTTP header and get it back

我正在编写一些测试软件来模拟路由器之类的东西。它将代表多个用户发送 URL 个请求。

是否有任何我可以发送的 HTTP GET header 字段,接收服务器将始终在响应中原封不动地发回给我,以便我可以将响应与用户相关联?

这是只在本地局域网上使用的测试软件,所以我不介意滥用一个字段,只要我把它原封不动地返回即可。

根据http 1.1 rfc,响应是:

  Response      = Status-Line               ; Section 6.1
                       *(( general-header        ; Section 4.5
                        | response-header        ; Section 6.2
                        | entity-header ) CRLF)  ; Section 7.1
                       CRLF
                       [ message-body ]          ; Section 7.2

这是符号:

   *rule
      The character "*" preceding an element indicates repetition. The
      full form is "<n>*<m>element" indicating at least <n> and at most
      <m> occurrences of element. Default values are 0 and infinity so
      that "*(element)" allows any number, including zero; "1*element"
      requires at least one; and "1*2element" allows one or two.

   [rule]
      Square brackets enclose optional elements; "[foo bar]" is
      equivalent to "*1(foo bar)".

因此,对服务器的唯一要求是响应状态代码,其他组件始终是可选的,这实际上意味着不需要发送任何 header 回

此外,this contains list of all possible headers、none 符合您的要求

我不确定 http 2.0,也许有人可以添加相关信息