From efbc3288ce4e01fe68aad837c062c36c37743a21 Mon Sep 17 00:00:00 2001
From: pavelxdd <pavel.otchertsov@gmail.com>
Date: Wed, 3 Apr 2019 10:18:17 +0300
Subject: [PATCH] http: basic auth: fix delay on Firefox

Firefox sends HTTP requests with "Connection: keep-alive" header.
When LWS responds with 401 and WWW-Authenticate header, Firefox
doesn't show an authentication dialog until connection is closed.
Adding "Content-Length: 0" solves the problem.
---
 lib/roles/http/server/server.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/lib/roles/http/server/server.c b/lib/roles/http/server/server.c
index 72931560..6ff73df5 100644
--- a/lib/roles/http/server/server.c
+++ b/lib/roles/http/server/server.c
@@ -828,6 +828,9 @@ lws_unauthorised_basic_auth(struct lws *wsi)
 			(unsigned char *)buf, n, &p, end))
 		return -1;
 
+	if (lws_add_http_header_content_length(wsi, 0, &p, end))
+		return -1;
+
 	if (lws_finalize_http_header(wsi, &p, end))
 		return -1;
 
-- 
GitLab