diff options
author | bptato <nincsnevem662@gmail.com> | 2025-03-26 20:08:12 +0100 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2025-03-26 20:08:12 +0100 |
commit | d0797e696475784e4f104b4ee48050c51a69f501 (patch) | |
tree | edb842da21e1f8adf298e091573270f9171ba684 | |
parent | 76320b4a2b8677581ea45da644a7cc3a71544821 (diff) | |
download | chawan-d0797e696475784e4f104b4ee48050c51a69f501.tar.gz |
newhttp: send connected directly after establishing connection
-rw-r--r-- | bonus/newhttp/http.nim | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/bonus/newhttp/http.nim b/bonus/newhttp/http.nim index 6bc90558..c6ebfa2c 100644 --- a/bonus/newhttp/http.nim +++ b/bonus/newhttp/http.nim @@ -251,14 +251,12 @@ proc handleStatus(op: HTTPHandle; iq: openArray[char]): int = if c != '\n' or not op.line.startsWithIgnoreCase("HTTP/1.1") and not op.line.startsWithIgnoreCase("HTTP/1.0"): - op.os.die("InvalidResponse", "malformed status line") + quit(1) let codes = op.line.until(' ', "HTTP/1.0 ".len) let code = parseUInt16(codes) if codes.len > 3 or code.isNone: - op.os.die("InvalidResponse", "malformed status line") - let buf = "Cha-Control: Connected\r\n" & - "Status: " & $code.get & "\r\n" & - "Cha-Control: ControlDone\r\n" + quit(1) + let buf = "Status: " & $code.get & "\r\nCha-Control: ControlDone\r\n" if not op.os.writeDataLoop(buf): quit(1) op.lineState = lsNone @@ -458,6 +456,8 @@ proc main() = while (let n = ps.readData(iq); n > 0): if not op.ps.writeDataLoop(iq.toOpenArray(0, n - 1)): os.die("ConnectionRefused", "error sending request body") + if not os.writeDataLoop("Cha-Control: Connected\r\n"): + quit(1) block readResponse: while (let n = ps.readData(iq); n > 0): var m = 0 |