Skip to content

Provide a user API for retrieving additional parameters from request cookies #1509

Closed

Description

@jackm

Checklist

  • There are no similar issues or pull requests for this yet.
  • I discussed this idea on the communitydiscussions chat and feedback is positive.

Is your feature related to a problem? Please describe.

Provide a user API for retrieving httpx.Cookie object parameters from request cookies such as cookie expiry date, cookie path, secure flag, etc.
Right now it is only possible to get a cookie's value via httpx.Cookies.get(). No other cookie parameters are exposed via a user accessible API.

Describe alternatives you considered

The only way to get these parameters is to manually pull them out of the cookie jar by accessing the internal variables. This should be discouraged as internal implementation details are not guaranteed to be stable after each new version. Also due to the way objects in the cookie jar are structured you need to know the cookie path ahead of time to use as a dict key in order to access the httpx.Cookie object within.

e.g.

>>> r = httpx.get('http://httpbin.org/cookies/set?chocolate=chip', allow_redirects=False)
>>> r.cookies.jar._cookies[r.request.url.host]['/']['chocolate']
Cookie(version=0, name='chocolate', value='chip', port=None, port_specified=False, domain='httpbin.org', domain_specified=False, domain_initial_dot=False, path='/', path_specified=True, secure=False, expires=None, discard=True, comment=None, comment_url=None, rest={}, rfc2109=False)

Additional context

See discussions/1497

Activity

  1. locked and limited conversation to collaborators on Mar 15, 2021
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