Surround IPv6 addresses by square braquets in HTTP CONNECT requests

This commit is contained in:
Amaury Van Bemten 2020-05-13 10:15:41 +02:00 committed by Aliaksei Levin
parent 89b37e9f4c
commit 7a2feba897

View File

@ -20,7 +20,13 @@ void HttpProxy::send_connect() {
CHECK(state_ == State::SendConnect);
state_ = State::WaitConnectResponse;
string host = PSTRING() << ip_address_.get_ip_str() << ':' << ip_address_.get_port();
string host;
if (ip_address_.is_ipv6()) {
host = PSTRING() << "[" << ip_address_.get_ip_str() << "]" << ':' << ip_address_.get_port();
} else {
host = PSTRING() << ip_address_.get_ip_str() << ':' << ip_address_.get_port();
}
string proxy_authorization;
if (!username_.empty() || !password_.empty()) {
auto userinfo = PSTRING() << username_ << ':' << password_;