jgaa / restc-cpp

Modern C++ REST Client library
MIT License
614 stars 95 forks source link

Port number is not passed to proxy server #87

Open JackieKu opened 5 years ago

JackieKu commented 5 years ago

If a proxy is configured and the target service is running on a non-default port number (80 for http://, and 443 for https://), the connection always fails because the port number is not passed to the proxy server.

Purposed fix

diff --git a/src/RequestImpl.cpp b/src/RequestImpl.cpp
index bf7c862..f8028ab 100644
--- a/src/RequestImpl.cpp
+++ b/src/RequestImpl.cpp
@@ -179,7 +179,7 @@ private:
         request_buffer << Verb(request_type_) << ' ';

         if (properties_->proxy.type == Request::Proxy::Type::HTTP) {
-            request_buffer << parsed_url_.GetProtocolName() << parsed_url_.GetHost();
+            request_buffer << parsed_url_.GetProtocolName() << parsed_url_.GetHost() << ':' << parsed_url_.GetPort();
         }

         // Add arguments to the path as ?name=value&name=value...
jgaa commented 5 years ago

Thank you