gpt4 book ai didi

http - 为什么网络浏览器在发送 cookie 时不关心端口号?

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

我已经使用 firebug 手动创建了两个 cookie:

Cookie1=value1; expires=Sat, 29 Mar 2014 06:21:54 GMT; path=/Ex05Cookie; domain=localhost; HttpOnly
Cookie2=value2; expires=Sat, 29 Mar 2014 06:21:54 GMT; path=/Ex05Cookie; domain=localhost:8080; HttpOnly

唯一的区别是域属性,一个是localhost,另一个是端口号。

这是我尝试请求 http://localhost:8080/Ex05Cookie/ 时的 HTTP header :

GET /Ex05Cookie/ HTTP/1.1
Host: localhost:8080
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:20.0) Gecko/20100101 Firefox/20.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Cookie: Cookie1=value1
Connection: keep-alive
Cache-Control: max-age=0

其中 header 仅包含域为 localhost 的 Cookie1。

为什么我的 firefox 不发送 Cookie2 而不是 Cookie1?

最佳答案

这由 https://stackoverflow.com/a/4212964/14731 回答和 RFC 6265 的作者:

If we were designing cookies today, we'd definitely make it per-port. However, cookies are widely used on the Internet today and making this sort of change would break too many sites. For the most part, cookies are "done" in the sense that I wouldn't expect them to change much.Unfortunately, that means we stuck with cookies not respecting port number.

来源:https://groups.google.com/d/msg/comp.infosystems.www.misc/6WXdQ2RFhG8/VvOUuR3FNAUJ

关于http - 为什么网络浏览器在发送 cookie 时不关心端口号?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16271845/

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