Fixed request path when using proxy with HTTPS client
This commit is contained in:
parent
fa4dd130e5
commit
ddb5622f76
3 changed files with 5 additions and 17 deletions
|
|
@ -10,6 +10,7 @@
|
|||
#include <map>
|
||||
#include <random>
|
||||
#include <mutex>
|
||||
#include <type_traits>
|
||||
|
||||
namespace SimpleWeb {
|
||||
template <class socket_type>
|
||||
|
|
@ -68,8 +69,8 @@ namespace SimpleWeb {
|
|||
auto corrected_path=path;
|
||||
if(corrected_path=="")
|
||||
corrected_path="/";
|
||||
if(!config.proxy_server.empty())
|
||||
corrected_path=protocol()+"://"+host+':'+std::to_string(port)+corrected_path;
|
||||
if(!config.proxy_server.empty() && std::is_same<socket_type, boost::asio::ip::tcp::socket>::value)
|
||||
corrected_path="http://"+host+':'+std::to_string(port)+corrected_path;
|
||||
|
||||
boost::asio::streambuf write_buffer;
|
||||
std::ostream write_stream(&write_buffer);
|
||||
|
|
@ -121,8 +122,8 @@ namespace SimpleWeb {
|
|||
auto corrected_path=path;
|
||||
if(corrected_path=="")
|
||||
corrected_path="/";
|
||||
if(!config.proxy_server.empty())
|
||||
corrected_path=protocol()+"://"+host+':'+std::to_string(port)+corrected_path;
|
||||
if(!config.proxy_server.empty() && std::is_same<socket_type, boost::asio::ip::tcp::socket>::value)
|
||||
corrected_path="http://"+host+':'+std::to_string(port)+corrected_path;
|
||||
|
||||
content.seekp(0, std::ios::end);
|
||||
auto content_length=content.tellp();
|
||||
|
|
@ -199,7 +200,6 @@ namespace SimpleWeb {
|
|||
return parsed_host_port;
|
||||
}
|
||||
|
||||
virtual std::string protocol() const =0;
|
||||
virtual void connect()=0;
|
||||
|
||||
std::shared_ptr<boost::asio::deadline_timer> get_timeout_timer() {
|
||||
|
|
@ -366,10 +366,6 @@ namespace SimpleWeb {
|
|||
Client(const std::string& server_port_path) : ClientBase<HTTP>::ClientBase(server_port_path, 80) {}
|
||||
|
||||
protected:
|
||||
std::string protocol() const {
|
||||
return "http";
|
||||
}
|
||||
|
||||
void connect() {
|
||||
if(!socket || !socket->is_open()) {
|
||||
std::unique_ptr<boost::asio::ip::tcp::resolver::query> query;
|
||||
|
|
|
|||
|
|
@ -33,10 +33,6 @@ namespace SimpleWeb {
|
|||
protected:
|
||||
boost::asio::ssl::context context;
|
||||
|
||||
std::string protocol() const {
|
||||
return "https";
|
||||
}
|
||||
|
||||
void connect() {
|
||||
if(!socket || !socket->lowest_layer().is_open()) {
|
||||
std::unique_ptr<boost::asio::ip::tcp::resolver::query> query;
|
||||
|
|
|
|||
|
|
@ -48,10 +48,6 @@ class ClientTest : public ClientBase<HTTP> {
|
|||
public:
|
||||
ClientTest(const std::string& server_port_path) : ClientBase<HTTP>::ClientBase(server_port_path, 80) {}
|
||||
|
||||
std::string protocol() const {
|
||||
return "http";
|
||||
}
|
||||
|
||||
void connect() {}
|
||||
|
||||
bool constructor_parse_test1() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue