From 0bfb172a9e934755b6508a3f48febb3c5ebbca3b Mon Sep 17 00:00:00 2001 From: pavelxdd 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 bf848ae89..5119762eb 100644 --- a/lib/roles/http/server/server.c +++ b/lib/roles/http/server/server.c @@ -829,6 +829,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;