@@ -596,6 +596,10 @@ class RequestImpl : public Request {
596
596
tuple<string, string> GetRequestEndpoint () {
597
597
const auto proxy_type = properties_->proxy .type ;
598
598
599
+ // https connections via http proxy is not possible
600
+ assert (!(proxy_type == Request::Proxy::Type::HTTP
601
+ && parsed_url_.GetProtocol () == Url::Protocol::HTTPS));
602
+
599
603
if (proxy_type == Request::Proxy::Type::SOCKS5) {
600
604
string host;
601
605
uint16_t port = 0 ;
@@ -608,10 +612,9 @@ class RequestImpl : public Request {
608
612
return { host, to_string (port) };
609
613
}
610
614
611
- if ( (proxy_type == Request::Proxy::Type::HTTP &&
612
- parsed_url_.GetProtocol () == Url::Protocol::HTTP) ||
613
- (proxy_type == Request::Proxy::Type::HTTPS &&
614
- parsed_url_.GetProtocol () == Url::Protocol::HTTPS) ) {
615
+ if ( (proxy_type == Request::Proxy::Type::HTTP
616
+ && parsed_url_.GetProtocol () == Url::Protocol::HTTP)
617
+ || proxy_type == Request::Proxy::Type::HTTPS ) {
615
618
Url proxy {properties_->proxy .address .c_str ()};
616
619
617
620
RESTC_CPP_LOG_TRACE_ (" Using " << properties_->proxy .GetName ()
@@ -726,7 +729,8 @@ class RequestImpl : public Request {
726
729
727
730
const Connection::Type protocol_type =
728
731
(parsed_url_.GetProtocol () == Url::Protocol::HTTPS ||
729
- properties_->proxy .type == Request::Proxy::Type::HTTPS)
732
+ (properties_->proxy .type == Request::Proxy::Type::HTTPS
733
+ && parsed_url_.GetProtocol () == Url::Protocol::HTTPS))
730
734
? Connection::Type::HTTPS
731
735
: Connection::Type::HTTP;
732
736
@@ -861,6 +865,15 @@ class RequestImpl : public Request {
861
865
<< ex.what ()
862
866
<< " \" while connecting to " << endpoint);
863
867
break ; // Go to the next endpoint
868
+ } catch (const RequestFailedWithErrorException& ex) {
869
+ RESTC_CPP_LOG_WARN_ (" Connect to "
870
+ << endpoint
871
+ << " failed with HTTP protocol exception type: "
872
+ << typeid (ex).name ()
873
+ << " , message: " << ex.what ());
874
+
875
+ connection->GetSocket ().GetSocket ().close ();
876
+ break ; // Go to the next endpoint
864
877
} catch (const exception& ex) {
865
878
RESTC_CPP_LOG_WARN_ (" Connect to "
866
879
<< endpoint
0 commit comments