Add option to disable cookie persistence in Client/AsyncClient
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.5k
- Forks
- 78
- Avg merge
- 8h 59m
- Merged PRs (30d)
- 24
Description
Originally opened by
@fastilyon 2023-12-08 01:05:51 in encode/httpx
Initially raised as discussion #1533
I've been using httpx's AsyncClient as a web spider, however I have noticed that cookies are automatically persisted and there's no easy way to disable this. My workaround has been to subclass python's http.cookiejar.CookieJar like so:
from http.cookiejar import CookieJar
class NullCookieJar(CookieJar):
"""A CookieJar that rejects all cookies."""
def extract_cookies(self, *_):
"""For extracting and saving cookies. This implementation does nothing"""
pass
def set_cookie(self, _):
"""Normally for setting a cookie. This implementation does nothing"""
pass
Would it be possible to:
- add an option to disable cookie persistence to
Client/AsyncClientor - include this implementation of
NullCookieJarinhttpxas a utility class?
Thanks!
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the Client and AsyncClient entry points and trace how cookie storage is configured and updated. Compare the requested opt-out with the proposed NullCookieJar behavior; done means both clients provide a documented way to prevent cookie persistence, with tests covering the behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- networking
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100