diff options
author | bptato <nincsnevem662@gmail.com> | 2024-02-12 17:03:35 +0100 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2024-02-12 17:03:35 +0100 |
commit | 8e6783a45fba48dd8f63fe7486e4691f05220b52 (patch) | |
tree | 5aae9f9f95432609a497eea858c4a3401dac172b /src/loader/request.nim | |
parent | 69b1a7e7f6e0a675cd70805768162de5621e8279 (diff) | |
download | chawan-8e6783a45fba48dd8f63fe7486e4691f05220b52.tar.gz |
Remove CLONE BufferSource; cache document sources in tmpdir
At last all BufferSources are unified. To achieve the same effect as the previous CLONE source type, we now use the "fromcache" flag in Request. This *forces* the document to be streamed from the disk; if the file no longer exists for some reason, an error is returned (i.e. the document is not re-downloaded). For a document to be cached, it has to be the main document of the buffer (i.e. no additional resources requested with fetch()), and also not an x-htmloutput HTML file (for those, the original source is saved). The result is that toggleSource now always returns the actual source for e.g. markdown files, not the HTML-transformed version. Also, it is now possible to view the source of a document that is still being downloaded. buffer.sstream has almost been eliminated; it still exists, but only as a pseudo-buffer to interface with EncoderStream and DecoderStream. It no longer holds the entire source of a buffer at any point, and is cleared as soon as the buffer is completely loaded.
Diffstat (limited to 'src/loader/request.nim')
-rw-r--r-- | src/loader/request.nim | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/loader/request.nim b/src/loader/request.nim index 805345f3..fcad1681 100644 --- a/src/loader/request.nim +++ b/src/loader/request.nim @@ -9,6 +9,7 @@ import js/fromjs import js/javascript import js/jstypes import loader/headers +import loader/streamid import types/blob import types/formdata import types/referer @@ -80,8 +81,8 @@ type credentialsMode* {.jsget.}: CredentialsMode proxy*: URL #TODO do something with this canredir*: bool - clientFd*: int - clientPid*: int + fromcache*: bool + clientId*: StreamId ReadableStream* = ref object of Stream isource*: Stream @@ -164,7 +165,7 @@ func newRequest*(url: URL, httpMethod = HTTP_GET, headers = newHeaders(), body = opt(string), multipart = opt(FormData), mode = RequestMode.NO_CORS, credentialsMode = CredentialsMode.SAME_ORIGIN, destination = RequestDestination.NO_DESTINATION, proxy: URL = nil, - referrer: URL = nil, canredir = false): Request = + referrer: URL = nil, canredir = false, fromcache = false): Request = return Request( url: url, httpMethod: httpMethod, @@ -175,7 +176,9 @@ func newRequest*(url: URL, httpMethod = HTTP_GET, headers = newHeaders(), credentialsMode: credentialsMode, destination: destination, referer: referrer, - proxy: proxy + proxy: proxy, + canredir: canredir, + fromcache: fromcache ) func newRequest*(url: URL, httpMethod = HTTP_GET, |