From b61f36579c195682d38584604e59677a90322a5a Mon Sep 17 00:00:00 2001 From: yhirose Date: Thu, 20 Jan 2022 15:21:33 -0500 Subject: [PATCH] Fix #1166 --- httplib.h | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/httplib.h b/httplib.h index 0a6734b..b5e1e0f 100644 --- a/httplib.h +++ b/httplib.h @@ -4239,14 +4239,16 @@ inline std::pair make_digest_authentication_header( } } - auto field = - "Digest username=\"" + username + "\", realm=\"" + auth.at("realm") + - "\", nonce=\"" + auth.at("nonce") + "\", uri=\"" + req.path + - "\", algorithm=" + algo + - (qop.empty() ? ", response=\"" - : ", qop=" + qop + ", nc=\"" + nc + "\", cnonce=\"" + - cnonce + "\", response=\"") + - response + "\""; + auto opaque = (auth.find("opaque") != auth.end()) ? auth.at("opaque") : ""; + + auto field = "Digest username=\"" + username + "\", realm=\"" + + auth.at("realm") + "\", nonce=\"" + auth.at("nonce") + + "\", uri=\"" + req.path + "\", algorithm=" + algo + + (qop.empty() ? ", response=\"" + : ", qop=" + qop + ", nc=" + nc + ", cnonce=\"" + + cnonce + "\", response=\"") + + response + "\"" + + (opaque.empty() ? "" : ", opaque=\"" + opaque + "\""); auto key = is_proxy ? "Proxy-Authorization" : "Authorization"; return std::make_pair(key, field);