@@ -2477,17 +2477,17 @@ inline std::pair<std::string, std::string> make_range_header(Ranges ranges) {
2477
2477
2478
2478
inline std::pair<std::string, std::string>
2479
2479
make_basic_authentication_header (const std::string &username,
2480
- const std::string &password, bool proxy = false ) {
2480
+ const std::string &password, bool is_proxy = false ) {
2481
2481
auto field = " Basic " + detail::base64_encode (username + " :" + password);
2482
- auto key = proxy ? " Proxy-Authorization" : " Authorization" ;
2482
+ auto key = is_proxy ? " Proxy-Authorization" : " Authorization" ;
2483
2483
return std::make_pair (key, field);
2484
2484
}
2485
2485
2486
2486
#ifdef CPPHTTPLIB_OPENSSL_SUPPORT
2487
2487
inline std::pair<std::string, std::string> make_digest_authentication_header (
2488
2488
const Request &req, const std::map<std::string, std::string> &auth,
2489
2489
size_t cnonce_count, const std::string &cnonce, const std::string &username,
2490
- const std::string &password, bool proxy = false ) {
2490
+ const std::string &password, bool is_proxy = false ) {
2491
2491
using namespace std ;
2492
2492
2493
2493
string nc;
@@ -2527,15 +2527,15 @@ inline std::pair<std::string, std::string> make_digest_authentication_header(
2527
2527
" \" , algorithm=" + algo + " , qop=" + qop + " , nc=\" " + nc +
2528
2528
" \" , cnonce=\" " + cnonce + " \" , response=\" " + response + " \" " ;
2529
2529
2530
- auto key = proxy ? " Proxy-Authorization" : " Authorization" ;
2530
+ auto key = is_proxy ? " Proxy-Authorization" : " Authorization" ;
2531
2531
return std::make_pair (key, field);
2532
2532
}
2533
2533
#endif
2534
2534
2535
2535
inline bool parse_www_authenticate (const httplib::Response &res,
2536
2536
std::map<std::string, std::string> &auth,
2537
- bool proxy ) {
2538
- auto key = proxy ? " Proxy-Authenticate" : " WWW-Authenticate" ;
2537
+ bool is_proxy ) {
2538
+ auto key = is_proxy ? " Proxy-Authenticate" : " WWW-Authenticate" ;
2539
2539
if (res.has_header (key)) {
2540
2540
static auto re = std::regex (R"~( (?:(?:,\s*)?(.+?)=(?:"(.*?)"|([^,]*))))~" );
2541
2541
auto s = res.get_header_value (key);
@@ -3562,6 +3562,8 @@ inline bool Client::send(const Request &req, Response &res) {
3562
3562
std::map<std::string, std::string> auth;
3563
3563
if (parse_www_authenticate (res, auth, is_proxy)) {
3564
3564
Request new_req = req;
3565
+ auto key = is_proxy ? " Proxy-Authorization" : " WWW-Authorization" ;
3566
+ new_req.headers .erase (key);
3565
3567
new_req.headers .insert (make_digest_authentication_header (
3566
3568
req, auth, 1 , random_string (10 ), username, password, is_proxy));
3567
3569
0 commit comments