diff options
author | bptato <nincsnevem662@gmail.com> | 2023-02-05 17:48:37 +0100 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2023-02-05 17:48:37 +0100 |
commit | 21178cc60e1d4ba3a6780c5691b9cfb5e7908aa8 (patch) | |
tree | 8db0946d00b3f60600b8177d2df3914b227125e1 /src/ips | |
parent | 7e9408b80a5a8b12710ce8b14a4ee78900ee2be4 (diff) | |
download | chawan-21178cc60e1d4ba3a6780c5691b9cfb5e7908aa8.tar.gz |
Slightly improve request api (less crashes)
Diffstat (limited to 'src/ips')
-rw-r--r-- | src/ips/socketstream.nim | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/ips/socketstream.nim b/src/ips/socketstream.nim index af173d1a..88023f07 100644 --- a/src/ips/socketstream.nim +++ b/src/ips/socketstream.nim @@ -17,6 +17,7 @@ type SocketStream* = ref object of Stream proc sockReadData(s: Stream, buffer: pointer, len: int): int = assert len != 0 let s = SocketStream(s) + let wasend = s.isend if s.blk: while result < len: let n = s.source.recv(cast[pointer](cast[int](buffer) + result), len - result) @@ -31,8 +32,9 @@ proc sockReadData(s: Stream, buffer: pointer, len: int): int = else: result = s.source.recv(buffer, len) if result == 0: + if wasend: + raise newException(EOFError, "eof") s.isend = true - raise newException(EOFError, "eof") if result < 0: raisePosixIOError() elif result == 0: |