diff options
author | bptato <nincsnevem662@gmail.com> | 2024-03-02 03:54:55 +0100 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2024-03-02 03:54:55 +0100 |
commit | 77e252b77463696880f1584890c2d95a6a34c377 (patch) | |
tree | 0565bf7431ba23773a2256d1d06cbb05cec12895 /src/loader | |
parent | f955317b306308cf023239e7c790deb113ed1e67 (diff) | |
download | chawan-77e252b77463696880f1584890c2d95a6a34c377.tar.gz |
cgi: fix regression in header handling
it's a good idea to use the return value, but it must substitute atEnd.
Diffstat (limited to 'src/loader')
-rw-r--r-- | src/loader/cgi.nim | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/loader/cgi.nim b/src/loader/cgi.nim index d30f8fd1..cb6e8ae4 100644 --- a/src/loader/cgi.nim +++ b/src/loader/cgi.nim @@ -233,7 +233,8 @@ proc loadCGI*(handle: LoaderHandle, request: Request, cgiDir: seq[string], handle.sendResult(ERROR_CGI_NO_DATA) return var line: string - if not ps.readLine(line) or line == "": #\r\n + var hasMore = ps.readLine(line) + if line == "": # \r\n or EOF # no headers, body comes immediately handle.sendResult(0) # success else: @@ -241,16 +242,18 @@ proc loadCGI*(handle: LoaderHandle, request: Request, cgiDir: seq[string], if res == RESULT_ERROR: return var crlfFound = false - while not ps.atEnd and res == RESULT_CONTROL_CONTINUE: - if not ps.readLine(line) or line == "": # \r\n + while hasMore and res == RESULT_CONTROL_CONTINUE: + hasMore = ps.readLine(line) + if line == "": # \r\n crlfFound = true break res = handle.handleControlLine(line, headers, status) if res == RESULT_ERROR: return if not crlfFound: - while not ps.atEnd: - if not ps.readLine(line) or line == "": # \r\n + while hasMore: + hasMore = ps.readLine(line) + if line == "": # \r\n break handle.handleLine(line, headers) handle.sendStatus(status) |