diff options
author | bptato <nincsnevem662@gmail.com> | 2024-05-11 19:56:25 +0200 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2024-05-11 20:06:10 +0200 |
commit | b8345d19efdecb27139e011e92f89efbb7618c08 (patch) | |
tree | 5d0f3de089ef40f1f653ee386771e326f9847cd6 /src/local/client.nim | |
parent | 2c1d1899e424c5e055214d3647979f7f0ba4dcfe (diff) | |
download | chawan-b8345d19efdecb27139e011e92f89efbb7618c08.tar.gz |
buffer: fix multipart forms
* fix enctype not getting picked up * fix form data constructor requiring open() syscall (which gets blocked by our seccomp filter) * add closing boundary to multipart end * pass fds instead of path names through WebFile/Blob and send those through bufwriter/bufreader
Diffstat (limited to 'src/local/client.nim')
-rw-r--r-- | src/local/client.nim | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/local/client.nim b/src/local/client.nim index af5e89a0..dc79438e 100644 --- a/src/local/client.nim +++ b/src/local/client.nim @@ -658,11 +658,12 @@ proc clientLoadJSModule(ctx: JSContext; module_name: cstringConst; JS_ThrowTypeError(ctx, "Failed to open file %s", module_name) return nil -proc readBlob(client: Client; path: string): Option[WebFile] {.jsfunc.} = - try: - return some(newWebFile(path)) - except IOError: - discard +proc readBlob(client: Client; path: string): WebFile {.jsfunc.} = + let ps = newPosixStream(path, O_RDONLY, 0) + if ps == nil: + return nil + let name = path.afterLast('/') + return newWebFile(name, ps.fd) #TODO this is dumb proc readFile(client: Client; path: string): string {.jsfunc.} = |