net/tshttpproxy: support HTTP proxy environment credentials on Windows too

and some minor style nits.

Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
Brad Fitzpatrick
2021-02-17 21:23:39 -08:00
committed by Brad Fitzpatrick
parent 96a488e37e
commit 6a2c6541da
2 changed files with 18 additions and 16 deletions

View File

@@ -71,10 +71,6 @@ func GetAuthHeader(u *url.URL) (string, error) {
if fake := os.Getenv("TS_DEBUG_FAKE_PROXY_AUTH"); fake != "" {
return fake, nil
}
if sysAuthHeader != nil {
return sysAuthHeader(u)
}
if user := u.User.Username(); user != "" {
pass, ok := u.User.Password()
if !ok {
@@ -85,7 +81,9 @@ func GetAuthHeader(u *url.URL) (string, error) {
req.SetBasicAuth(user, pass)
return req.Header.Get("Authorization"), nil
}
if sysAuthHeader != nil {
return sysAuthHeader(u)
}
return "", nil
}