Skip to content

Commit 66d6897

Browse files
committed
fix formatting and error messages
1 parent 0eecd50 commit 66d6897

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

cmd/src/main.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"io"
88
"log"
99
"net"
10+
"net/http"
1011
"net/url"
1112
"os"
1213
"path/filepath"
@@ -303,6 +304,14 @@ func readConfig() (*config, error) {
303304
} else {
304305
return nil, errors.Newf("invalid proxy endpoint: %s", proxyStr)
305306
}
307+
} else {
308+
// no SRC_PROXY; check for the standard proxy env variables HTTP_PROXY, HTTPS_PROXY, and NO_PROXY
309+
if u, err := http.ProxyFromEnvironment(&http.Request{URL: cfg.endpointURL}); err != nil {
310+
// when there's an error, the value for the env variable is not a legit URL
311+
return nil, errors.Newf("invalid HTTP_PROXY or HTTPS_PROXY value: %w", err)
312+
} else {
313+
cfg.proxyURL = u
314+
}
306315
}
307316

308317
cfg.additionalHeaders = parseAdditionalHeaders()
@@ -343,7 +352,7 @@ func isValidUnixSocket(path string) (bool, error) {
343352
if os.IsNotExist(err) {
344353
return false, nil
345354
}
346-
return false, errors.Newf("not a UNIX Domain Socket: %v: %w", path, err)
355+
return false, errors.Newf("not a UNIX domain socket: %v: %w", path, err)
347356
}
348357
defer conn.Close()
349358

0 commit comments

Comments
 (0)