diff --git a/src/proto_htx.c b/src/proto_htx.c index 4573c6891..2a021938e 100644 --- a/src/proto_htx.c +++ b/src/proto_htx.c @@ -5435,10 +5435,12 @@ static int htx_reply_40x_unauthorized(struct stream *s, const char *auth_realm) if (!htx_add_header(htx, ist("Cache-Control"), ist("no-cache")) || !htx_add_header(htx, ist("Connection"), ist("close")) || - !htx_add_header(htx, ist("Content-Type"), ist("text/html")) || - !htx_add_header(htx, ist("Proxy-Authenticate"), ist2(trash.area, trash.data))) + !htx_add_header(htx, ist("Content-Type"), ist("text/html"))) + goto fail; + if (status == 401 && !htx_add_header(htx, ist("WWW-Authenticate"), ist2(trash.area, trash.data))) + goto fail; + if (status == 407 && !htx_add_header(htx, ist("Proxy-Authenticate"), ist2(trash.area, trash.data))) goto fail; - if (!htx_add_endof(htx, HTX_BLK_EOH) || !htx_add_data(htx, body) || !htx_add_endof(htx, HTX_BLK_EOM)) goto fail;