tshttp, derphttp: send Proxy-Authorization, not Authorization, to proxies

Whoops. But weirdly, sending Authorization sometimes worked?
This commit is contained in:
Brad Fitzpatrick
2020-08-28 20:58:14 -07:00
parent 3af2d671e6
commit 1e0be5a458
3 changed files with 20 additions and 4 deletions

View File

@@ -106,10 +106,14 @@ func getURL(ctx context.Context, urlStr string) error {
}
if proxyURL != nil {
auth, err := tshttpproxy.GetAuthHeader(proxyURL)
log.Printf("tshttpproxy.GetAuthHeader(%v) = %q, %v", proxyURL, auth, err)
if err == nil && auth != "" {
tr.ProxyConnectHeader.Set("Authorization", auth)
tr.ProxyConnectHeader.Set("Proxy-Authorization", auth)
}
const truncLen = 20
if len(auth) > truncLen {
auth = fmt.Sprintf("%s...(%d total bytes)", auth[:truncLen], len(auth))
}
log.Printf("tshttpproxy.GetAuthHeader(%v) for Proxy-Auth: = %q, %v", proxyURL, auth, err)
}
res, err := tr.RoundTrip(req)
if err != nil {