Closed darrelmiller closed 1 year ago
Good catch! The list items MUST be unique. I will specify this for now.
WDYT about switching Policy to a Dictionary?
This requires some tweak though e.g. prefixing the units with u
.
from http_sfv import Dictionary
# RateLimit-Limit: 100
# RateLimit-Policy: u100=10; unit="requests"
limit = Item()
limit.parse(b'100')
policies = Dictionary()
policies.parse(b'u100=10; unit="requests", u1000=200; unit="requests"')
policy = policies[f'u{limit.value}]
cc: @mnot
I'd use a short name for the policy, so that it could be referred to separately; e.g.,
RateLimit-Policy: shortreqlimit; unit=requests; limit=100; window=10
RateLimit: shortreqlimit; remaining=15; reset=5
If server defines two policies, e.g.
and the response header contains,
How do I know if I can make 2 more requests, or download 2 more bytes?
Is having multiple policies with different quota units not allowed?