From 8e6783a45fba48dd8f63fe7486e4691f05220b52 Mon Sep 17 00:00:00 2001 From: bptato Date: Mon, 12 Feb 2024 17:03:35 +0100 Subject: 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. --- src/loader/response.nim | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/loader/response.nim') diff --git a/src/loader/response.nim b/src/loader/response.nim index a8bc31e4..0869a73e 100644 --- a/src/loader/response.nim +++ b/src/loader/response.nim @@ -3,6 +3,7 @@ import std/unicode import bindings/quickjs import io/promise +import io/socketstream import js/error import js/javascript import loader/headers @@ -35,7 +36,7 @@ type responseType* {.jsget: "type".}: ResponseType res*: int fd*: int - body*: Stream + body*: SocketStream bodyUsed* {.jsget.}: bool contentType*: string status* {.jsget.}: uint16 @@ -50,8 +51,8 @@ type jsDestructor(Response) -proc newResponse*(res: int, request: Request, fd = -1, stream: Stream = nil): - Response = +proc newResponse*(res: int, request: Request, fd = -1, + stream: SocketStream = nil): Response = return Response( res: res, url: request.url, -- cgit 1.4.1-2-gfad0