diff options
| author | bptato <nincsnevem662@gmail.com> | 2024-03-24 14:12:27 +0100 |
|---|---|---|
| committer | bptato <nincsnevem662@gmail.com> | 2024-03-24 14:21:01 +0100 |
| commit | fb21b1e4f0ee0e55e9556bf1f399d00d5eae26e4 (patch) | |
| tree | c532aa98ee6bedf19b840f4ea0c7360a42407fbf /src/types | |
| parent | b27deb7672c53e3ee59f91b7091e83ab28a8318d (diff) | |
| download | chawan-fb21b1e4f0ee0e55e9556bf1f399d00d5eae26e4.tar.gz | |
io: derive DynStream from RootObj (not Stream)
This way they are no longer compatible, but we no longer need them to
be compatible anyway.
(This also forces us to throw out the old serialize module, and use
packet writers everywhere.)
Diffstat (limited to 'src/types')
| -rw-r--r-- | src/types/formdata.nim | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/types/formdata.nim b/src/types/formdata.nim index 29817e54..b353b814 100644 --- a/src/types/formdata.nim +++ b/src/types/formdata.nim @@ -1,6 +1,7 @@ -import std/streams import std/strutils +import io/dynstream +import io/filestream import js/javascript import types/blob import utils/twtstr @@ -56,7 +57,7 @@ proc calcLength*(this: FormData): int = proc getContentType*(this: FormData): string = return "multipart/form-data; boundary=" & this.boundary -proc writeEntry*(stream: Stream, entry: FormDataEntry, boundary: string) = +proc writeEntry*(stream: DynStream; entry: FormDataEntry; boundary: string) = stream.write("--" & boundary & "\r\n") let name = percentEncode(entry.name, {'"', '\r', '\n'}) if entry.isstr: @@ -74,17 +75,17 @@ proc writeEntry*(stream: Stream, entry: FormDataEntry, boundary: string) = blob.ctype stream.write("Content-Type: " & ctype & "\r\n") if blob.isfile: - let fs = newFileStream(WebFile(blob).path) + let fs = newDynFileStream(WebFile(blob).path) if fs != nil: var buf {.noinit.}: array[4096, uint8] while true: - let n = fs.readData(addr buf[0], 4096) + let n = fs.recvData(addr buf[0], 4096) if n == 0: break - stream.writeData(addr buf[0], n) + stream.sendDataLoop(addr buf[0], n) if n < buf.len: break else: - stream.writeData(blob.buffer, int(blob.size)) + stream.sendDataLoop(blob.buffer, int(blob.size)) stream.write("\r\n") stream.write("\r\n") |