Skip to content

Commit

Permalink
host = host + port
Browse files Browse the repository at this point in the history
  • Loading branch information
sibkod committed Oct 27, 2023
1 parent 49e7fcc commit 4305328
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions vlib/net/http/http_proxy.v
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,15 @@ pub fn new_http_proxy(raw_url string) !&HttpProxy {
if port == 0 {
if scheme == 'https' {
port = 443
host += ':' + port.str()
} else if scheme == 'http' {
port = 80
host += ':' + port.str()
}
}
if port == 0 {
return error("Unknown port")
}

return &HttpProxy{
scheme: scheme
Expand Down Expand Up @@ -73,17 +78,19 @@ fn (pr &HttpProxy) build_proxy_headers(request &Request, host string, path strin
uheaders << '${key}: ${val}\r\n'
}
uheaders << request.build_request_cookies_header()
if pr.username != '' {
mut authinfo := ''
if ['http', 'https'].contains(pr.scheme) {
if pr.username != '' {
mut authinfo := ''

authinfo += pr.username
if pr.password != '' {
authinfo += ':${pr.password}'
}
authinfo += pr.username
if pr.password != '' {
authinfo += ':${pr.password}'
}

encoded_authinfo := base64.encode(authinfo.bytes())
encoded_authinfo := base64.encode(authinfo.bytes())

uheaders << 'Proxy-Authorization: Basic ${encoded_authinfo}\r\n'
uheaders << 'Proxy-Authorization: Basic ${encoded_authinfo}\r\n'
}
}

version := Version.v1_1
Expand Down

0 comments on commit 4305328

Please sign in to comment.