From 7adb5cfb425dd927b3e78f1a9da75d825f6a3904 Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Mon, 24 Mar 2025 21:56:42 +0000 Subject: Respect HEAD in cgi Signed-off-by: Laurent Bercot --- src/tipideed/cgi.c | 9 +++++++-- src/tipideed/tipideed.c | 4 +++- 2 files changed, 10 insertions(+), 3 deletions(-) (limited to 'src/tipideed') diff --git a/src/tipideed/cgi.c b/src/tipideed/cgi.c index 21e21db..069d045 100644 --- a/src/tipideed/cgi.c +++ b/src/tipideed/cgi.c @@ -338,13 +338,18 @@ static inline int do_cgi (tipidee_rql *rql, char const *docroot, char const *con buffer_putsnoflush(buffer_1, fmt) ; buffer_putnoflush(buffer_1, "\r\n", 2) ; } - else if (autochunk) + else if (autochunk && rql->m != TIPIDEE_METHOD_HEAD) buffer_putsnoflush(buffer_1, "Transfer-Encoding: chunked\r\n") ; buffer_putnoflush(buffer_1, "\r\n", 2) ; tipidee_log_answer(g.logv, rql, status, rbodylen) ; - if (contentlength) + if (rql->m == TIPIDEE_METHOD_HEAD) + { + if (!buffer_timed_flush_g(buffer_1, &deadline)) + strerr_diefu1sys(111, "write to stdout") ; + } + else if (contentlength) { size_t len ; struct iovec v[2] ; diff --git a/src/tipideed/tipideed.c b/src/tipideed/tipideed.c index a5f9fcd..35abdf2 100644 --- a/src/tipideed/tipideed.c +++ b/src/tipideed/tipideed.c @@ -292,7 +292,9 @@ static inline int serve (tipidee_rql *rql, char const *docroot, char *uribuf, ti if (!(ra.flags & TIPIDEE_RA_FLAG_CGI)) { if (infopath[0]) { respond_404(rql, docroot) ; return 0 ; } - if (rql->m == TIPIDEE_METHOD_POST) exit_405(rql, docroot, 0) ; + if (rql->m != TIPIDEE_METHOD_GET + && rql->m != TIPIDEE_METHOD_HEAD + && rql->m != TIPIDEE_METHOD_OPTIONS) exit_405(rql, docroot, 0) ; } if (rql->m == TIPIDEE_METHOD_OPTIONS) -- cgit v1.3.1