mirror of
https://github.com/zedeus/nitter
synced 2026-09-05 14:49:32 +00:00
Skip x-ratelimit headers when served from cache
This commit is contained in:
parent
1639315699
commit
5a2df5df2e
1 changed files with 3 additions and 1 deletions
|
|
@ -8,6 +8,7 @@ const
|
||||||
rlRemaining = "x-rate-limit-remaining"
|
rlRemaining = "x-rate-limit-remaining"
|
||||||
rlReset = "x-rate-limit-reset"
|
rlReset = "x-rate-limit-reset"
|
||||||
rlLimit = "x-rate-limit-limit"
|
rlLimit = "x-rate-limit-limit"
|
||||||
|
npCache = "x-np-cache"
|
||||||
errorsToSkip = {null, doesntExist, tweetNotFound, timeout, unauthorized, badRequest}
|
errorsToSkip = {null, doesntExist, tweetNotFound, timeout, unauthorized, badRequest}
|
||||||
|
|
||||||
var
|
var
|
||||||
|
|
@ -139,7 +140,8 @@ template fetchImpl(result, fetchBody) {.dirty.} =
|
||||||
echo "[sessions] transient 404 (empty body), retrying: ", url.path, ", session: ", session.pretty
|
echo "[sessions] transient 404 (empty body), retrying: ", url.path, ", session: ", session.pretty
|
||||||
raise rateLimitError()
|
raise rateLimitError()
|
||||||
|
|
||||||
if resp.headers.hasKey(rlRemaining):
|
let cacheStatus = resp.headers.getOrDefault(npCache)
|
||||||
|
if cacheStatus notin ["HIT", "STALE"] and resp.headers.hasKey(rlRemaining):
|
||||||
let
|
let
|
||||||
remaining = parseInt(resp.headers[rlRemaining])
|
remaining = parseInt(resp.headers[rlRemaining])
|
||||||
reset = parseInt(resp.headers[rlReset])
|
reset = parseInt(resp.headers[rlReset])
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue