GithubHelp home page GithubHelp logo

Comments (3)

suikabreaker avatar suikabreaker commented on June 9, 2024

Note this is not a problem of cookie support.

from pycurl-requests.

dcoles avatar dcoles commented on June 9, 2024

Hi, Thank you for your bug report.

I tried reproducing this behaviour in Requests:

>>> import requests
>>> r = requests.get('https://httpbin.org/cookies/set?foo=x&bar=y', allow_redirects=False)
>>> print(r.headers.get("Set-Cookie", None))
foo=x; Path=/, bar=y; Path=/
>>> import pycurl_requests as requests
>>> r = requests.get('https://httpbin.org/cookies/set?foo=x&bar=y', allow_redirects=False)
>>> print(r.headers.get("Set-Cookie", None))
foo=x; Path=/

There's a bug in build_response where only the first key is extracted from the HTTPMessage object. Instead these values should be joined with , as defined by RFC-7230 section 3.3.2:

A recipient MAY combine multiple header fields with the same field
name into one "field-name: field-value" pair, without changing the
semantics of the message, by appending each subsequent field value to
the combined field value in order, 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; a proxy MUST NOT change the order of these field values when
forwarding a message.

However, Set-Cookie is special:

Note: In practice, the "Set-Cookie" header field ([RFC6265]) often
appears multiple times in a response message and does not use the
list syntax, violating the above requirements on multiple header
fields with the same name. Since it cannot be combined into a
single field-value, recipients ought to handle "Set-Cookie" as a
special case while processing header fields. (See Appendix A.2.3
of [Kri2001] for details.)

(This is an important reason for adding dedicated cookie support)

However, for accessing Set-Cookie via the headers attribute, I'm likely to imitate Request's behaviour and just use a , to join the headers.

from pycurl-requests.

dcoles avatar dcoles commented on June 9, 2024

Fix released in pycurl-requests-0.2.1.

from pycurl-requests.

Related Issues (6)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.