首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >HTTP请求中是否允许有多个Cookie标头?

HTTP请求中是否允许有多个Cookie标头?
EN

Stack Overflow用户
提问于 2013-05-01 01:38:09
回答 1查看 59.1K关注 0票数 108

通常,浏览器将cookies分组到单个Cookie标头中,例如:

Cookie: a=1; b=2

该标准是否允许将这些作为单独的标头发送,例如:

Cookie: a=1
Cookie: b=2

或者它们必须总是在同一条线上?

EN

回答 1

Stack Overflow用户

发布于 2018-03-21 22:46:21

现在它在HTTP/2 (RFC 7540)中是允许的,它指定:

    8.1.2.5.  Compressing the Cookie Header Field

   The Cookie header field [COOKIE] uses a semi-colon (";") to delimit
   cookie-pairs (or "crumbs").  This header field doesn't follow the
   list construction rules in HTTP (see [RFC7230], Section 3.2.2), which
   prevents cookie-pairs from being separated into different name-value
   pairs.  This can significantly reduce compression efficiency as
   individual cookie-pairs are updated.

   To allow for better compression efficiency, the Cookie header field
   MAY be split into separate header fields, each with one or more
   cookie-pairs.  If there are multiple Cookie header fields after
   decompression, these MUST be concatenated into a single octet string
   using the two-octet delimiter of 0x3B, 0x20 (the ASCII string "; ")
   before being passed into a non-HTTP/2 context, such as an HTTP/1.1
   connection, or a generic HTTP server application.

   Therefore, the following two lists of Cookie header fields are
   semantically equivalent.

     cookie: a=b; c=d; e=f

     cookie: a=b
     cookie: c=d
     cookie: e=f
票数 36
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16305814

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档