-
-
Notifications
You must be signed in to change notification settings - Fork 998
Closed
Description
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
Metadata
Metadata
Assignees
Labels
No labels