Cleanup of Client::connect methods

This commit is contained in:
eidheim 2016-11-24 18:05:19 +01:00
commit 4141b76574
2 changed files with 10 additions and 20 deletions

View file

@ -39,19 +39,14 @@ namespace SimpleWeb {
void connect() {
if(!socket || !socket->lowest_layer().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]
resolver.async_resolve(*query, [this]
(const boost::system::error_code &ec, boost::asio::ip::tcp::resolver::iterator it){
if(!ec) {
{