about summary refs log tree commit diff stats
path: root/src/loader/loader.nim
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2023-12-29 19:50:06 +0100
committerbptato <nincsnevem662@gmail.com>2023-12-29 19:50:06 +0100
commit82fdf7df545442182c1cf0298a7629f8acf0532d (patch)
tree8ba90c8efcf94ea0ae6076f4283176a9513e7b7e /src/loader/loader.nim
parentc580087775ccbacd86799262ce5b53f314a1c893 (diff)
downloadchawan-82fdf7df545442182c1cf0298a7629f8acf0532d.tar.gz
loader: send error message str for disallowed URL
buffer was crashing with an EOFError otherwise
Diffstat (limited to 'src/loader/loader.nim')
-rw-r--r--src/loader/loader.nim6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/loader/loader.nim b/src/loader/loader.nim
index 72f30cbd..de70c551 100644
--- a/src/loader/loader.nim
+++ b/src/loader/loader.nim
@@ -163,11 +163,11 @@ proc loadResource(ctx: LoaderContext, request: Request, handle: LoaderHandle) =
 proc onLoad(ctx: LoaderContext, stream: SocketStream) =
   var request: Request
   stream.sread(request)
+  let handle = newLoaderHandle(stream, request.canredir)
   if not ctx.config.filter.match(request.url):
-    stream.swrite(ERROR_DISALLOWED_URL)
-    stream.close()
+    discard handle.sendResult(ERROR_DISALLOWED_URL)
+    handle.close()
   else:
-    let handle = newLoaderHandle(stream, request.canredir)
     for k, v in ctx.config.defaultheaders.table:
       if k notin request.headers.table:
         request.headers.table[k] = v