Unable to override cookie policy
KKomarov opened this issue · comments
I would like to be able to override the cookie policy used by a Client when making a request. However, overriding the cookie policy on the cookie jar of the Client or of the Request object has had no effect. These lines of code explains why:
Line 334 in 497b315
Line 1030 in 497b315
When initialise request from existing cookies (which is Cookies object of Client), it discards policy object from source Cookies object.
Line 400 in 497b315
The cookie jars of both the client and the request are merged into a newly constructed CookieJar, discarding the policies of both.
What I expected to be able to do, and what isn't working currently, is something like the following:
cookie = MozillaCookieJar(filename='cookies.txt', policy=MyCookiePolicy())
cookie.load()
session = httpx.Client(headers=headers, cookies=cookie)
session.get(url)
In my opinion Policy from CookieJar in Client should not be discarded. When CookieJar object passed in request then policy from request should override policy from Client.