diff options
author | bptato <nincsnevem662@gmail.com> | 2023-06-05 14:04:46 +0200 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2023-06-05 14:05:20 +0200 |
commit | c5d774073a90d122c757b677c149e11c7564e8e0 (patch) | |
tree | 187c747efb7fbf6e438ffad9c3ae6a45720e96dd /src | |
parent | 06c0dd1741af58eb55c27601b070010ad6c50dc8 (diff) | |
download | chawan-c5d774073a90d122c757b677c149e11c7564e8e0.tar.gz |
buffer: call handleError before handleRead & misc
Diffstat (limited to 'src')
-rw-r--r-- | src/buffer/buffer.nim | 12 | ||||
-rw-r--r-- | src/io/loader.nim | 2 |
2 files changed, 7 insertions, 7 deletions
diff --git a/src/buffer/buffer.nim b/src/buffer/buffer.nim index d668a01d..dc41ba6c 100644 --- a/src/buffer/buffer.nim +++ b/src/buffer/buffer.nim @@ -1137,7 +1137,7 @@ proc handleRead(buffer: Buffer, fd: int) = discard #TODO hack else: assert false -proc handleError(buffer: Buffer, fd: int) = +proc handleError(buffer: Buffer, fd: int, err: OSErrorCode) = if fd == buffer.rfd: # Connection reset by peer, probably. Close the buffer. buffer.alive = false @@ -1145,26 +1145,26 @@ proc handleError(buffer: Buffer, fd: int) = buffer.onload() elif fd in buffer.loader.connecting: # probably shouldn't happen. TODO - assert false + assert false, $fd & ": " & $err elif fd in buffer.loader.ongoing: #TODO something with readablestream? discard elif buffer.fd == -1 and fd == buffer.oldfd: discard #TODO hack else: - assert false + assert false, $fd & ": " & $err proc runBuffer(buffer: Buffer, rfd: int) = buffer.rfd = rfd while buffer.alive: let events = buffer.selector.select(-1) for event in events: + if Read in event.events: + buffer.handleRead(event.fd) if Error in event.events: - buffer.handleError(event.fd) + buffer.handleError(event.fd, event.errorCode) if not buffer.alive: break - if Read in event.events: - buffer.handleRead(event.fd) if Event.Timer in event.events: assert buffer.window != nil assert buffer.window.timeouts.runTimeoutFd(event.fd) diff --git a/src/io/loader.nim b/src/io/loader.nim index 1102b4b5..9e9865c3 100644 --- a/src/io/loader.nim +++ b/src/io/loader.nim @@ -233,7 +233,7 @@ proc applyHeaders(request: Request, response: Response) = destination = request.destination) else: response.redirect = newRequest(url.get, request.httpmethod, - body = request.body, # multipart = request.multipart, TODO TODO TODO + body = request.body, multipart = request.multipart, mode = request.mode, credentialsMode = request.credentialsMode, destination = request.destination) |