Controller ignores some flags when use `force_cache=True`
Closed this issue · 1 comments
yazmolod commented
Description
According to documentation, force_cache
flag disables headers validating and RFC9111 rules following. From this description I assume that this flag should not affect on other flags like cacheable_status_codes
or cacheable_methods
, etc. However it does
To reproduce
import hishel
_controller = hishel.Controller(
force_cache=True,
cacheable_status_codes=[200],
cacheable_methods=['get']
)
_storage = hishel.SQLiteStorage()
with hishel.CacheClient(controller=_controller, storage=_storage) as client:
client.get('https://httpbin.org/status/503')
client.post('https://httpbin.org/status/200')
r1 = client.get('https://httpbin.org/status/503')
r2 = client.post('https://httpbin.org/status/200')
print(r1.request.method, r1.status_code, r1.extensions['from_cache']) # GET 503 True
print(r2.request.method, r2.status_code, r2.extensions['from_cache']) # POST 200 True
Environment
- Windows 11 64bit
- Python 3.12.3
- Hishel 0.0.30
karpetrosyan commented
Agree, force_cache
should affect only RFC related things, and not the controller configuration. Marking as a bug