From 75d78f817734d169eefe5ccfcf09e289c3e2a0f9 Mon Sep 17 00:00:00 2001 From: "C. McEnroe" Date: Thu, 16 Jul 2020 12:49:02 -0400 Subject: Fix HEAD responses You need to call khttp_body for the CGI response to be valid, otherwise nginx will just 502 Bad Gateway it. --- contexts.c | 5 +++-- events.c | 5 +++-- networks.c | 5 +++-- search.c | 5 +++-- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/contexts.c b/contexts.c index 69afcdc..5eba403 100644 --- a/contexts.c +++ b/contexts.c @@ -61,12 +61,13 @@ enum kcgi_err contextsPage(struct kreq *req) { struct Scope scope = pageScope(req); if (!scope.network) return httpFail(req, KHTTP_400); - enum kcgi_err error = httpHead(req, KHTTP_200, KMIME_TEXT_HTML); + enum kcgi_err error = 0 + || httpHead(req, KHTTP_200, KMIME_TEXT_HTML) + || khttp_body(req); if (req->method == KMETHOD_HEAD) return error; struct khtmlreq html; error = error - || khttp_body(req) || khtml_open(&html, req, 0) || htmlHead(&html, scope.network) || htmlNav(&html, scope); diff --git a/events.c b/events.c index 65b869b..e5b0777 100644 --- a/events.c +++ b/events.c @@ -201,12 +201,13 @@ enum kcgi_err eventsPage(struct kreq *req) { ? req->fieldmap[Before]->parsed.s : req->fieldmap[After]->parsed.s; - enum kcgi_err error = httpHead(req, KHTTP_200, KMIME_TEXT_HTML); + enum kcgi_err error = 0 + || httpHead(req, KHTTP_200, KMIME_TEXT_HTML) + || khttp_body(req); if (req->method == KMETHOD_HEAD) return error; struct khtmlreq html; error = error - || khttp_body(req) || khtml_open(&html, req, 0) || htmlHead(&html, scope.context) || htmlNav(&html, scope) diff --git a/networks.c b/networks.c index f2f059a..c92da21 100644 --- a/networks.c +++ b/networks.c @@ -47,12 +47,13 @@ const char *NetworksQuery = SQL( enum kcgi_err networksPage(struct kreq *req) { struct Scope scope = {0}; - enum kcgi_err error = httpHead(req, KHTTP_200, KMIME_TEXT_HTML); + enum kcgi_err error = 0 + || httpHead(req, KHTTP_200, KMIME_TEXT_HTML) + || khttp_body(req); if (req->method == KMETHOD_HEAD) return error; struct khtmlreq html; error = error - || khttp_body(req) || khtml_open(&html, req, 0) || htmlHead(&html, "Litterbox") || htmlNav(&html, scope); diff --git a/search.c b/search.c index 878e0f7..af29685 100644 --- a/search.c +++ b/search.c @@ -52,12 +52,13 @@ enum kcgi_err searchPage(struct kreq *req) { int64_t offset = 0; if (req->fieldmap[Offset]) offset = req->fieldmap[Offset]->parsed.i; - enum kcgi_err error = httpHead(req, KHTTP_200, KMIME_TEXT_HTML); + enum kcgi_err error = 0 + || httpHead(req, KHTTP_200, KMIME_TEXT_HTML) + || khttp_body(req); if (req->method == KMETHOD_HEAD) return error; struct khtmlreq html; error = error - || khttp_body(req) || khtml_open(&html, req, 0) || htmlHead(&html, scope.query) || htmlNav(&html, scope) -- cgit 1.4.1