diff options
| author | bptato <nincsnevem662@gmail.com> | 2024-06-29 12:32:17 +0200 |
|---|---|---|
| committer | bptato <nincsnevem662@gmail.com> | 2024-06-29 12:50:16 +0200 |
| commit | 2e50aa23237da76802d2a61cb7426bf51c122d14 (patch) | |
| tree | 9ed3f42f9ef3f6a6f97c4118bc5fbc90248f00ce /src/types | |
| parent | e7786e39e38ddf5ec75b95cc19e1bee108cd37d2 (diff) | |
| download | chawan-2e50aa23237da76802d2a61cb7426bf51c122d14.tar.gz | |
dom, pager: cache images from network
With many limitations:
* slightly randomized expiry, so it's harder to fingerprint
* only images. so e.g. CSS is still left uncached
* it's per-buffer and non-persistent, so images are still redownloaded
for every new page load
so it's more of an image sharing between placements than true caching.
Diffstat (limited to 'src/types')
| -rw-r--r-- | src/types/cookie.nim | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/src/types/cookie.nim b/src/types/cookie.nim index 1b1c82cd..4f7b3ef4 100644 --- a/src/types/cookie.nim +++ b/src/types/cookie.nim @@ -188,7 +188,7 @@ proc add*(cookiejar: CookieJar; cookies: seq[Cookie]) = proc serialize*(cookiejar: CookieJar; url: URL): string = if not cookiejar.filter.match(url): return "" # fail - let t = now().toTime().toUnix() + let t = getTime().utc().toTime().toUnix() #TODO sort for i in countdown(cookiejar.cookies.high, 0): let cookie = cookiejar.cookies[i] @@ -208,10 +208,7 @@ proc serialize*(cookiejar: CookieJar; url: URL): string = result &= cookie.value proc newCookie*(str: string; url: URL = nil): JSResult[Cookie] {.jsctor.} = - let cookie = Cookie( - expires: -1, - created: now().toTime().toUnix() - ) + let cookie = Cookie(expires: -1, created: getTime().utc().toTime().toUnix()) var first = true var haspath = false var hasdomain = false @@ -222,12 +219,8 @@ proc newCookie*(str: string; url: URL = nil): JSResult[Cookie] {.jsctor.} = first = false continue let part = part.strip(leading = true, trailing = false, AsciiWhitespace) - var n = 0 - for i in 0..part.high: - if part[i] == '=': - n = i - break - if n == 0: + let n = part.find('=') + if n <= 0: continue let key = part.substr(0, n - 1) let val = part.substr(n + 1) |