1
0
Fork 0
mirror of https://github.com/gocsaf/csaf.git synced 2025-12-22 11:55:40 +01:00

Improve https get diagnostics, add verbose option

* Implement a logging client and activate it using verbose parameter or option
   in checker and aggregator.

Co-authored-by: Sascha L. Teichmann <sascha.teichmann@intevation.de>
This commit is contained in:
Bernhard E. Reiter 2022-06-02 15:07:55 +02:00 committed by GitHub
parent e4011ea4cc
commit a849ac0d5f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 70 additions and 14 deletions

View file

@ -270,9 +270,9 @@ func (p *processor) httpClient() util.Client {
return p.client
}
client := http.Client{}
hClient := http.Client{}
client.CheckRedirect = p.checkRedirect
hClient.CheckRedirect = p.checkRedirect
var tlsConfig tls.Config
if p.opts.Insecure {
@ -287,17 +287,25 @@ func (p *processor) httpClient() util.Client {
tlsConfig.Certificates = []tls.Certificate{cert}
}
client.Transport = &http.Transport{
hClient.Transport = &http.Transport{
TLSClientConfig: &tlsConfig,
}
var client util.Client
if p.opts.Verbose {
client = &util.LoggingClient{Client: &hClient}
} else {
client = &hClient
}
if p.opts.Rate == nil {
p.client = &client
return &client
p.client = client
return client
}
p.client = &util.LimitingClient{
Client: &client,
Client: client,
Limiter: rate.NewLimiter(rate.Limit(*p.opts.Rate), 1),
}