When we disable "Transfer-Encoding: chunked" in the fastcgi backend
authorflorian <florian@openbsd.org>
Wed, 19 May 2021 19:42:53 +0000 (19:42 +0000)
committerflorian <florian@openbsd.org>
Wed, 19 May 2021 19:42:53 +0000 (19:42 +0000)
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

index 31d7322..ab796da 100644 (file)
@@ -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 <florian@openbsd.org>
@@ -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? */