diff options
author | bptato <nincsnevem662@gmail.com> | 2024-03-28 15:52:35 +0100 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2024-03-28 15:52:35 +0100 |
commit | 6716b3a0013949dc8a0d51e39ae4724755305762 (patch) | |
tree | a31ed9956bfd90e994d09d707ee97dc6c12e4fae /adapter/protocol | |
parent | b530ccc899a8cc8c63bad29abe1e479eb999b167 (diff) | |
download | chawan-6716b3a0013949dc8a0d51e39ae4724755305762.tar.gz |
http: fix broken early hint handling
The empty string comparison here was in fact pointless; in cw-out.c, libcurl only calls cwb (which is curlWriteHeader in this case) if blen is not 0, so the string will never be empty. (Instead, it is expected to be \r\n; I've added \n too since CGI can already parse headers like that.) Normally it still worked because we just passed through the line to cgi.nim. However, it choked horribly on HTTP/2 early hints.
Diffstat (limited to 'adapter/protocol')
-rw-r--r-- | adapter/protocol/http.nim | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/adapter/protocol/http.nim b/adapter/protocol/http.nim index 2bdd6858..4e2d529d 100644 --- a/adapter/protocol/http.nim +++ b/adapter/protocol/http.nim @@ -45,7 +45,7 @@ proc curlWriteHeader(p: cstring, size, nitems: csize_t, userdata: pointer): puts("Status: " & $status & "\nCha-Control: ControlDone\n") return nitems - if line == "": + if line == "\r\n" or line == "\n": # empty line (last, before body) if op.earlyhint == EARLY_HINT_STARTED: # ignore; we do not have a way to stream headers yet. @@ -53,6 +53,7 @@ proc curlWriteHeader(p: cstring, size, nitems: csize_t, userdata: pointer): # reset statusline; we are awaiting the next line. op.statusline = false return nitems + puts("\r\n") return nitems if op.earlyhint != EARLY_HINT_STARTED: |