diff options
author | eidheim <eidheim@gmail.com> | 2021-03-02 15:57:49 +0300 |
---|---|---|
committer | eidheim <eidheim@gmail.com> | 2021-03-02 15:57:49 +0300 |
commit | daafe592bbac1771db3fc219bfb99ba6c8d51409 (patch) | |
tree | 078b9867919f779997e1e3ff026fc839fedaae09 | |
parent | c9b1ec39e0515684255a740dd84fb7eadcbe7712 (diff) |
Slight cleanup of proxy authorization
-rw-r--r-- | client_wss.hpp | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/client_wss.hpp b/client_wss.hpp index f782179..9c5d1e0 100644 --- a/client_wss.hpp +++ b/client_wss.hpp @@ -86,15 +86,11 @@ namespace SimpleWeb { auto streambuf = std::make_shared<asio::streambuf>(); std::ostream ostream(streambuf.get()); auto host_port = this->host + ':' + std::to_string(this->port); - if(!this->config.proxy_auth.empty()) { - auto credentials_base64 = std::make_shared<std::string>(Crypto::Base64::encode(this->config.proxy_auth)); - ostream << "CONNECT " + host_port + " HTTP/1.1\r\n" - << "Proxy-Authorization: Basic " << *credentials_base64 << "\r\n" - << "Host: " << host_port << "\r\n\r\n"; - } else { - ostream << "CONNECT " + host_port + " HTTP/1.1\r\n" - << "Host: " << host_port << "\r\n\r\n"; - } + ostream << "CONNECT " + host_port + " HTTP/1.1\r\n" + << "Host: " << host_port << "\r\n"; + if(!this->config.proxy_auth.empty()) + ostream << "Proxy-Authorization: Basic " << Crypto::Base64::encode(this->config.proxy_auth) << "\r\n"; + ostream << "\r\n"; connection->set_timeout(this->config.timeout_request); asio::async_write(connection->socket->next_layer(), *streambuf, [this, connection, streambuf](const error_code &ec, std::size_t /*bytes_transferred*/) { connection->cancel_timeout(); |