gpt4 book ai didi

http - 将单个 HTTP header 的多个值添加到请求或响应的标准

转载 作者:可可西里 更新时间:2023-11-01 15:03:48 25 4
gpt4 key购买 nike

如果我想添加一个值列表作为 HTTP header ,是否有标准方法可以做到这一点?我在 RFC 822 中找不到任何东西(我很容易理解)。例如,是逗号分隔值标准或分号分隔值。有标准吗?

例子:

Key: value1;value2;value3

最佳答案

您需要查看 HTTP 规范 RFC 2616它说:

Multiple message-header fields with the same field-name MAY be present in a message if and only if the entire field-value for that header field is defined as a comma-separated list [i.e., #(values)]. It MUST be possible to combine the multiple header fields into one "field-name: field-value" pair, without changing the semantics of the message, by appending each subsequent field-value to the first, each separated by a comma. The order in which header fields with the same field-name are received is therefore significant to the interpretation of the combined field value, and thus a proxy MUST NOT change the order of these field values when a message is forwarded.

这意味着您可以在具有不同值的响应中多次发送相同的 header ,只要这些值可以使用逗号相互附加即可。这也意味着您可以通过用逗号连接它们来在单个 header 中发送多个值。

所以在你的情况下它将是:

Key: value1,value2,value3

关于http - 将单个 HTTP header 的多个值添加到请求或响应的标准,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3096888/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com