From 7953d84589cf479c3d40ce77665d42ba41c484de Mon Sep 17 00:00:00 2001 From: florian Date: Wed, 19 May 2021 19:42:53 +0000 Subject: [PATCH] When we disable "Transfer-Encoding: chunked" in the fastcgi backend because we are going to send an empty body we have to provide "Content-Length: 0" otherwise some browsers (Firefox, Safari) just hang until httpd(8) closes the connection. Problem reported by Matthias Pressfreund, debugged with weerd@ who pointed out that the problem is browser dependent. OK tracey --- usr.sbin/httpd/server_fcgi.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/usr.sbin/httpd/server_fcgi.c b/usr.sbin/httpd/server_fcgi.c index 31d7322e9f7..ab796da4950 100644 --- a/usr.sbin/httpd/server_fcgi.c +++ b/usr.sbin/httpd/server_fcgi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: server_fcgi.c,v 1.86 2021/05/17 09:26:52 florian Exp $ */ +/* $OpenBSD: server_fcgi.c,v 1.87 2021/05/19 19:42:53 florian Exp $ */ /* * Copyright (c) 2014 Florian Obser @@ -636,6 +636,13 @@ server_fcgi_header(struct client *clt, unsigned int code) if (kv_add(&resp->http_headers, "Transfer-Encoding", "chunked") == NULL) return (-1); + } else { + key.kv_key = "Content-Length"; + if ((kv = kv_find(&resp->http_headers, &key)) == NULL) { + if (kv_add(&resp->http_headers, + "Content-Length", "0") == NULL) + return (-1); + } } /* Is it a persistent connection? */ -- 2.20.1