diff options
author | Omar Polo <op@omarpolo.com> | 2021-02-01 22:04:51 +0000 |
---|---|---|
committer | Omar Polo <op@omarpolo.com> | 2021-02-01 22:04:51 +0000 |
commit | 35744950aa0953bee3035400e8035af844a675ba (patch) | |
tree | d80acba024c823266f6bf279ce1ca94115e829bc /regress | |
parent | b06f80cdf43be684bd57f9674917d2479bc0d317 (diff) |
simplify handle_cgi
Now that I got rid of the enum+switch, adding more state is easier.
Before, we used an hack to remember if we had read the CGI reply or
not (c->code = -1).
This introduces a new state, handle_cgi_reply that reads the CGI
script reply, logs it, and only then switches to handle_cgi.
handle_cgi itself is cleaner, now it only reads into c->sbuf and send
what it had red.
We even get, almost for free, the 42 error. If read exists with -1 or
0 from in handle_cgi_reply, we return a proper error to the client.
We can extend this further in the future and also try to validate the
CGI reply (for now we're only looking for a \n).
Diffstat (limited to 'regress')
-rwxr-xr-x | regress/runtime | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/regress/runtime b/regress/runtime index cd35b70..5ffd83f 100755 --- a/regress/runtime +++ b/regress/runtime @@ -163,7 +163,7 @@ eq "$(head /slow)" "20 text/gemini" "Unexpected head for /slow" eq "$(get /slow)" "# hello world$ln" "Unexpected body for /slow" echo OK GET /slow with cgi -eq "$(head /err)" "" "Unexpected head for /err" +eq "$(head /err)" "42 CGI error" "Unexpected head for /err" eq "$(get /err)" "" "Unexpected body for /err" echo OK GET /err with cgi |