diff options
author | bptato <nincsnevem662@gmail.com> | 2024-02-26 15:26:46 +0100 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2024-02-26 15:26:46 +0100 |
commit | 973e8f942855fe9a17f0245948984bf9841f9ffa (patch) | |
tree | 8ab60f658881df53901d4a843fd5c090b8c632bc /src/loader/loaderhandle.nim | |
parent | cf1e026b85972135170c80e22b83b4567a5d1099 (diff) | |
download | chawan-973e8f942855fe9a17f0245948984bf9841f9ffa.tar.gz |
loader: clean up regular file loading
* Get rid of sostream hack This is no longer needed, and was in fact causing loadStream to get stuck with redirects on regular files (i.e. the common case of receiving <file on stdin without a -T content type override). * Unify loading from cache and stdin regular file code paths Until now, loadFromCache was completely sync. This is not a huge problem, but it's better to make it async *and* not have two separate procedures for reading regular files. (In fact, loadFromCache had *another* bug related to its output fd not being added to outputMap.) * Extra: remove ansi2html select error handling It was broken, because it didn't handle read events before the error. Also unnecessary, since recvData breaks from the loop on n == 0.
Diffstat (limited to 'src/loader/loaderhandle.nim')
-rw-r--r-- | src/loader/loaderhandle.nim | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/loader/loaderhandle.nim b/src/loader/loaderhandle.nim index eb6d61ba..24f4a584 100644 --- a/src/loader/loaderhandle.nim +++ b/src/loader/loaderhandle.nim @@ -51,6 +51,12 @@ type dealloc(buffer.page) buffer.page = nil +# for debugging +func `$`*(buffer: LoaderBuffer): string = + var s = newString(buffer.len) + copyMem(addr s[0], addr buffer.page[0], buffer.len) + return s + # Create a new loader handle, with the output stream ostream. proc newLoaderHandle*(ostream: PosixStream, canredir: bool, clientId: StreamId): LoaderHandle = @@ -137,6 +143,7 @@ proc sendHeaders*(handle: LoaderHandle, headers: Headers) = let fd = sostream.recvFileHandle() output.sostream = sostream output.ostream = newPosixStream(fd) + output.clientId = NullStreamId proc recvData*(ps: PosixStream, buffer: LoaderBuffer): int {.inline.} = let n = ps.recvData(addr buffer.page[0], buffer.cap) |