From b93d97258c0327aa8fa41b357c42728ad23fd814 Mon Sep 17 00:00:00 2001 From: Lorenz Stechauner Date: Tue, 3 Jan 2023 18:43:49 +0100 Subject: [PATCH] Reverse proxy error docs also with HEAD --- src/worker/proxy_handler.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/worker/proxy_handler.c b/src/worker/proxy_handler.c index 27a546e..f245045 100644 --- a/src/worker/proxy_handler.c +++ b/src/worker/proxy_handler.c @@ -77,10 +77,11 @@ static int proxy_handler_1(client_ctx_t *ctx) { const char *content_length_f = http_get_header_field(&res->hdr, "Content-Length"); const char *content_encoding = http_get_header_field(&res->hdr, "Content-Encoding"); if (content_encoding == NULL && ( + strcmp(ctx->req.method, "HEAD") == 0 || (content_length_f != NULL && strcmp(content_length_f, "0") == 0) || (content_type != NULL && content_length_f != NULL && strncmp(content_type, "text/html", 9) == 0))) { - long content_len = strtol(content_length_f, NULL, 10); + long content_len = (content_length_f != NULL) ? strtol(content_length_f, NULL, 10) : 0; if (content_len <= sizeof(ctx->msg_content) - 1) { if (status->status != 101) { status->status = res->status->code;