Improve HttpProxy logging.

This commit is contained in:
levlam 2024-07-23 15:54:56 +03:00
parent 88c2fd50e5
commit 2c81189790

View File

@ -26,6 +26,7 @@ void HttpProxy::send_connect() {
if (!username_.empty() || !password_.empty()) { if (!username_.empty() || !password_.empty()) {
auto userinfo = PSTRING() << username_ << ':' << password_; auto userinfo = PSTRING() << username_ << ':' << password_;
proxy_authorization = PSTRING() << "Proxy-Authorization: basic " << base64_encode(userinfo) << "\r\n"; proxy_authorization = PSTRING() << "Proxy-Authorization: basic " << base64_encode(userinfo) << "\r\n";
VLOG(proxy) << "Use credentials to connect to proxy: " << proxy_authorization;
} }
fd_.output_buffer().append(PSLICE() << "CONNECT " << host << " HTTP/1.1\r\n" fd_.output_buffer().append(PSLICE() << "CONNECT " << host << " HTTP/1.1\r\n"
<< "Host: " << host << "\r\n" << "Host: " << host << "\r\n"
@ -47,7 +48,7 @@ Status HttpProxy::wait_connect_response() {
char buf[1024]; char buf[1024];
size_t len = min(sizeof(buf), it.size()); size_t len = min(sizeof(buf), it.size());
it.advance(len, MutableSlice{buf, sizeof(buf)}); it.advance(len, MutableSlice{buf, sizeof(buf)});
VLOG(proxy) << "Failed to connect: " << format::escaped(Slice(buf, len)); VLOG(proxy) << "Failed to connect: " << format::escaped(begin) << format::escaped(Slice(buf, len));
return Status::Error(PSLICE() << "Failed to connect to " << ip_address_.get_ip_host() << ':' return Status::Error(PSLICE() << "Failed to connect to " << ip_address_.get_ip_host() << ':'
<< ip_address_.get_port()); << ip_address_.get_port());
} }