diff options
author | bptato <nincsnevem662@gmail.com> | 2023-10-25 12:35:11 +0200 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2023-10-25 12:48:30 +0200 |
commit | 3f0a183d48a44cbbe642842fb60b69cca9e83390 (patch) | |
tree | 0aad7dfeaa3a9265e030b2ed2739de4e042a69a2 /src/loader/request.nim | |
parent | b6e5390ec286747ce6789f9cfec54dec8dc18fa3 (diff) | |
download | chawan-3f0a183d48a44cbbe642842fb60b69cca9e83390.tar.gz |
reduce new() usage
Diffstat (limited to 'src/loader/request.nim')
-rw-r--r-- | src/loader/request.nim | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/loader/request.nim b/src/loader/request.nim index 7596a0a2..78d38723 100644 --- a/src/loader/request.nim +++ b/src/loader/request.nim @@ -145,17 +145,17 @@ proc rsClose(s: Stream) = {.cast(tags: [WriteIOEffect]).}: #TODO TODO TODO ew. s.isource.setPosition(s.isource.getPosition() + len) proc newReadableStream*(isource: Stream): ReadableStream = - new(result) - result.isource = isource - result.readDataImpl = rsReadData - result.atEndImpl = rsAtEnd - result.closeImpl = rsClose var len: int - result.isource.read(len) - if len == 0: - result.isend = true - else: - result.isource.readStr(len, result.buf) + isource.read(len) + result = ReadableStream( + isource: isource, + readDataImpl: rsReadData, + atEndImpl: rsAtEnd, + closeImpl: rsClose, + isend: len == 0 + ) + if len != 0: + isource.readStr(len, result.buf) func newRequest*(url: URL, httpmethod = HTTP_GET, headers = newHeaders(), body = opt(string), multipart = opt(FormData), mode = RequestMode.NO_CORS, |