@@ -4615,8 +4615,7 @@ inline bool Server::write_response_core(Stream &strm, bool close_connection,
4615
4615
if (!res.body .empty ()) {
4616
4616
if (!strm.write (res.body )) { ret = false ; }
4617
4617
} else if (res.content_provider_ ) {
4618
- if (write_content_with_provider (strm, req, res, boundary,
4619
- content_type)) {
4618
+ if (write_content_with_provider (strm, req, res, boundary, content_type)) {
4620
4619
res.content_provider_success_ = true ;
4621
4620
} else {
4622
4621
res.content_provider_success_ = false ;
@@ -5551,8 +5550,8 @@ inline bool ClientImpl::handle_request(Stream &strm, Request &req,
5551
5550
if (detail::parse_www_authenticate (res, auth, is_proxy)) {
5552
5551
Request new_req = req;
5553
5552
new_req.authorization_count_ += 1 ;
5554
- auto key = is_proxy ? " Proxy-Authorization" : " Authorization " ;
5555
- new_req. headers . erase (key );
5553
+ new_req. headers . erase ( is_proxy ? " Proxy-Authorization"
5554
+ : " Authorization " );
5556
5555
new_req.headers .insert (detail::make_digest_authentication_header (
5557
5556
req, auth, new_req.authorization_count_ , detail::random_string (10 ),
5558
5557
username, password, is_proxy));
@@ -5649,7 +5648,11 @@ inline bool ClientImpl::write_content_with_provider(Stream &strm,
5649
5648
inline bool ClientImpl::write_request (Stream &strm, Request &req,
5650
5649
bool close_connection, Error &error) {
5651
5650
// Prepare additional headers
5652
- if (close_connection) { req.headers .emplace (" Connection" , " close" ); }
5651
+ if (close_connection) {
5652
+ if (!req.has_header (" Connection" )) {
5653
+ req.headers .emplace (" Connection" , " close" );
5654
+ }
5655
+ }
5653
5656
5654
5657
if (!req.has_header (" Host" )) {
5655
5658
if (is_ssl ()) {
@@ -5676,8 +5679,10 @@ inline bool ClientImpl::write_request(Stream &strm, Request &req,
5676
5679
if (req.body .empty ()) {
5677
5680
if (req.content_provider_ ) {
5678
5681
if (!req.is_chunked_content_provider_ ) {
5679
- auto length = std::to_string (req.content_length_ );
5680
- req.headers .emplace (" Content-Length" , length);
5682
+ if (!req.has_header (" Content-Length" )) {
5683
+ auto length = std::to_string (req.content_length_ );
5684
+ req.headers .emplace (" Content-Length" , length);
5685
+ }
5681
5686
}
5682
5687
} else {
5683
5688
if (req.method == " POST" || req.method == " PUT" ||
@@ -5697,24 +5702,32 @@ inline bool ClientImpl::write_request(Stream &strm, Request &req,
5697
5702
}
5698
5703
5699
5704
if (!basic_auth_password_.empty () || !basic_auth_username_.empty ()) {
5700
- req.headers .insert (make_basic_authentication_header (
5701
- basic_auth_username_, basic_auth_password_, false ));
5705
+ if (!req.has_header (" Authorization" )) {
5706
+ req.headers .insert (make_basic_authentication_header (
5707
+ basic_auth_username_, basic_auth_password_, false ));
5708
+ }
5702
5709
}
5703
5710
5704
5711
if (!proxy_basic_auth_username_.empty () &&
5705
5712
!proxy_basic_auth_password_.empty ()) {
5706
- req.headers .insert (make_basic_authentication_header (
5707
- proxy_basic_auth_username_, proxy_basic_auth_password_, true ));
5713
+ if (!req.has_header (" Proxy-Authorization" )) {
5714
+ req.headers .insert (make_basic_authentication_header (
5715
+ proxy_basic_auth_username_, proxy_basic_auth_password_, true ));
5716
+ }
5708
5717
}
5709
5718
5710
5719
if (!bearer_token_auth_token_.empty ()) {
5711
- req.headers .insert (make_bearer_token_authentication_header (
5712
- bearer_token_auth_token_, false ));
5720
+ if (!req.has_header (" Authorization" )) {
5721
+ req.headers .insert (make_bearer_token_authentication_header (
5722
+ bearer_token_auth_token_, false ));
5723
+ }
5713
5724
}
5714
5725
5715
5726
if (!proxy_bearer_token_auth_token_.empty ()) {
5716
- req.headers .insert (make_bearer_token_authentication_header (
5717
- proxy_bearer_token_auth_token_, true ));
5727
+ if (!req.has_header (" Proxy-Authorization" )) {
5728
+ req.headers .insert (make_bearer_token_authentication_header (
5729
+ proxy_bearer_token_auth_token_, true ));
5730
+ }
5718
5731
}
5719
5732
5720
5733
// Request line and headers
@@ -6687,8 +6700,9 @@ inline ssize_t SSLSocketStream::read(char *ptr, size_t size) {
6687
6700
auto err = SSL_get_error (ssl_, ret);
6688
6701
int n = 1000 ;
6689
6702
#ifdef _WIN32
6690
- while (--n >= 0 && (err == SSL_ERROR_WANT_READ ||
6691
- err == SSL_ERROR_SYSCALL && WSAGetLastError () == WSAETIMEDOUT)) {
6703
+ while (--n >= 0 &&
6704
+ (err == SSL_ERROR_WANT_READ ||
6705
+ err == SSL_ERROR_SYSCALL && WSAGetLastError () == WSAETIMEDOUT)) {
6692
6706
#else
6693
6707
while (--n >= 0 && err == SSL_ERROR_WANT_READ) {
6694
6708
#endif
0 commit comments