mirror of
https://github.com/gocsaf/csaf.git
synced 2025-12-22 11:55:40 +01:00
feat: log redirects (#458)
* feat: log redirects * improved logging and renamed function
This commit is contained in:
parent
0c9516ac08
commit
49da14d47f
1 changed files with 16 additions and 0 deletions
|
|
@ -92,10 +92,26 @@ func (d *downloader) addStats(o *stats) {
|
|||
d.stats.add(o)
|
||||
}
|
||||
|
||||
// logRedirect logs redirects of the http client.
|
||||
func logRedirect(req *http.Request, via []*http.Request) error {
|
||||
vs := make([]string, len(via))
|
||||
for i, v := range via {
|
||||
vs[i] = v.URL.String()
|
||||
}
|
||||
slog.Debug("Redirecting",
|
||||
"to", req.URL.String(),
|
||||
"via", strings.Join(vs, " -> "))
|
||||
return nil
|
||||
}
|
||||
|
||||
func (d *downloader) httpClient() util.Client {
|
||||
|
||||
hClient := http.Client{}
|
||||
|
||||
if d.cfg.LogLevel.slogLevel() <= slog.LevelDebug {
|
||||
hClient.CheckRedirect = logRedirect
|
||||
}
|
||||
|
||||
var tlsConfig tls.Config
|
||||
if d.cfg.Insecure {
|
||||
tlsConfig.InsecureSkipVerify = true
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue