New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CookieJar cookies should not be sorted #86232
Comments
By default python handle cookies based on regular Netscape cookie protocol and the protocol defined by RFC 2965. There is a behavior in python which sort cookies in CookieJar by default: Line 1220 in 975d10a
Moreover there is no definition in the 2965 about the cookie ordering in Cookie Header when cookies have equal-length path fields. This is a undesirable behavior when working with certain libraries like requests. psf/requests#5630 In this case browser implements the RFC 6265 which obsoletes the RFC 2965. Therefore The behavior is based on https://tools.ietf.org/html/rfc6265#section-5.4: This means that the order of the cookies with same path attribute in Cookie header follow the Set-Cookie order in the HTTP response. RFC 6265 compliance is not what this issue is meant rather it imply on the sorting of cookies which is unnecessary here and not mentioned in RFC 2965 or the regular Netscape cookie protocol. Thanks in advance for looking into this issue Regards. |
The seems reasonable to me. Likely, the sorting was originally added to make the execution order deterministic. Now that dicts remember insertion order, that is no longer necessary. Helpfully, the docs do not specify sorting, so there is no guaranteed behavior. That said, there is some risk that applications or their tests depend on the existing behavior. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: