Cleanup of Client::connect methods
This commit is contained in:
parent
f8cae4fde5
commit
4141b76574
2 changed files with 10 additions and 20 deletions
|
|
@ -372,19 +372,14 @@ namespace SimpleWeb {
|
|||
|
||||
void connect() {
|
||||
if(!socket || !socket->is_open()) {
|
||||
std::string host, port;
|
||||
if(config.proxy_server.empty()) {
|
||||
host=this->host;
|
||||
port=std::to_string(this->port);
|
||||
}
|
||||
std::unique_ptr<boost::asio::ip::tcp::resolver::query> query;
|
||||
if(config.proxy_server.empty())
|
||||
query=std::unique_ptr<boost::asio::ip::tcp::resolver::query>(new boost::asio::ip::tcp::resolver::query(host, std::to_string(port)));
|
||||
else {
|
||||
auto proxy_host_port=parse_host_port(config.proxy_server, 0);
|
||||
host=proxy_host_port.first;
|
||||
port=std::to_string(proxy_host_port.second);
|
||||
query=std::unique_ptr<boost::asio::ip::tcp::resolver::query>(new boost::asio::ip::tcp::resolver::query(proxy_host_port.first, std::to_string(proxy_host_port.second)));
|
||||
}
|
||||
boost::asio::ip::tcp::resolver::query query(host, port);
|
||||
|
||||
resolver.async_resolve(query, [this](const boost::system::error_code &ec,
|
||||
resolver.async_resolve(*query, [this](const boost::system::error_code &ec,
|
||||
boost::asio::ip::tcp::resolver::iterator it){
|
||||
if(!ec) {
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue