Skip to content
This repository was archived by the owner on Jan 13, 2021. It is now read-only.
This repository was archived by the owner on Jan 13, 2021. It is now read-only.

Using hyper.contrib.HTTP20Adapter with requests.session ignores set-cookie header and does not set cookies. #392

Description

@Margesh92

I am using hyper.contrib.HTTP20Adapter with requests in python.
When session is started with requests (with HTTP20Adapter) and url is fetched, it does not set cookies as per 'set-cookie' header.
So, session.cookies.get_dict() returns an empty dict {}.

Activity

  1. BarryThrill commented on Apr 26, 2019

    @BarryThrill

    I have the same issue, did you solve it?

  2. zjcnew commented on May 25, 2019

    @zjcnew

    I urgently hope to support the automatic management of request and response cookies as soon as possible.

  3. user223989 commented on Jun 3, 2019

    @user223989

    Is there any workaround for this? I have just come across the issue and it is a game breaking problem!

  4. xCuri0 commented on Jul 23, 2019

    @xCuri0

    Same issue. I've confirmed I'm actually receiving the cookies since I can see set-cookie in Wireshark

  5. crablab commented on Jul 31, 2019

    @crablab

    This is in #393 but hasn't been merged 🤔

    I have this same problem so it would be nice if it could be fixed!

    @Lukasa? 🙏

  6. xCuri0 commented on Aug 1, 2019

    @xCuri0

    @crablab that fix does not work correctly. it doesn't add all the cookies i see in wireshark

  7. crablab commented on Aug 1, 2019

    @crablab

    It is a bit of a dumster fire to be honest 🔥

    I might have a look at fixing this myself but I've never looked at the Hyper source before so 🤷‍♂️

  8. divinehawk commented on Dec 5, 2019

    @divinehawk

    #405 appears to fix this issue in both Python2 and Python3.

  9. paulzaf1992 commented on Apr 14, 2020

    @paulzaf1992

    @divinehawk I have applied the #405 fix but still no luck...

    Specifically, what I 'm doing is that I mount hyper.contrib.HTTP20Adapter to a requests.Session in python3 and I am trying to get a specific cookie from the RequestsCookieJar of the response.

    However, despite the fact that the response headers contain several 'Set-Cookie' headers, the CookieJar remains empty.

    I also added debug messages inside the FakeOriginalResponse.get_all() method in order to see the contents of the "values" variable that this method returns. I see that "values" contains all of the "Set-Cookie" cookies' values.

    Am I missing something else?

  10. paulzaf1992 commented on Apr 24, 2020

    @paulzaf1992

    Just came up with a solution.

    In the #405 fix I simply replaced the line
    if n.decode('utf-8') == name.lower():
    with:
    if n.decode('utf-8').lower() == name.lower():
    because I noticed that wihout it, the if was never true.

    And finally I placed the call to extract_cookies_to_jar() right before the return statement because its final argument needs the information we fake. So instead of calling it like
    extract_cookies_to_jar(response.cookies, request, response)
    I called it like:
    extract_cookies_to_jar(response.cookies, request, response.raw)

    Hope this saves someone the 4 weeks I lost over this...

  11. xingzhisg commented on May 8, 2020

    @xingzhisg

    If I get it right, the HTTP/2 specification (RFC7540 8.1.2 HTTP Header Fields) requires all field names to be in lowercase, so n.decode('utf-8').lower() is not necessary here.

  12. paulzaf1992 commented on May 8, 2020

    @paulzaf1992

    @xingzhisg that's what I thought as well and actually this is why it took me 4 weeks to solve this. I just happened to check this out of dispair, in order to be sure that it wasn't creating any problems. And after I checked that it works with it, I then reverted back and cross-checked that it failed without lower() in order to be 100% sure.
    I may have been missing something all along and I 'd appreciate any thoughts on it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions