mirror of
https://github.com/gocsaf/csaf.git
synced 2025-12-22 05:40:11 +01:00
Use a default user agent
This commit is contained in:
parent
257c316894
commit
0ab851a874
5 changed files with 19 additions and 15 deletions
|
|
@ -301,6 +301,11 @@ func (c *config) httpClient(p *provider) util.Client {
|
|||
Client: client,
|
||||
Header: c.ExtraHeader,
|
||||
}
|
||||
default:
|
||||
client = &util.HeaderClient{
|
||||
Client: client,
|
||||
Header: http.Header{},
|
||||
}
|
||||
}
|
||||
|
||||
if c.Verbose {
|
||||
|
|
|
|||
|
|
@ -435,12 +435,10 @@ func (p *processor) fullClient() util.Client {
|
|||
client := util.Client(&hClient)
|
||||
|
||||
// Add extra headers.
|
||||
if len(p.cfg.ExtraHeader) > 0 {
|
||||
client = &util.HeaderClient{
|
||||
Client: client,
|
||||
Header: p.cfg.ExtraHeader,
|
||||
}
|
||||
}
|
||||
|
||||
// Add optional URL logging.
|
||||
if p.cfg.Verbose {
|
||||
|
|
|
|||
|
|
@ -126,12 +126,10 @@ func (d *downloader) httpClient() util.Client {
|
|||
client := util.Client(&hClient)
|
||||
|
||||
// Add extra headers.
|
||||
if len(d.cfg.ExtraHeader) > 0 {
|
||||
client = &util.HeaderClient{
|
||||
Client: client,
|
||||
Header: d.cfg.ExtraHeader,
|
||||
}
|
||||
}
|
||||
|
||||
// Add optional URL logging.
|
||||
if d.cfg.verbose() {
|
||||
|
|
|
|||
|
|
@ -111,12 +111,10 @@ func (f *forwarder) httpClient() util.Client {
|
|||
client := util.Client(&hClient)
|
||||
|
||||
// Add extra headers.
|
||||
if len(f.cfg.ForwardHeader) > 0 {
|
||||
client = &util.HeaderClient{
|
||||
Client: client,
|
||||
Header: f.cfg.ForwardHeader,
|
||||
}
|
||||
}
|
||||
|
||||
// Add optional URL logging.
|
||||
if f.cfg.verbose() {
|
||||
|
|
|
|||
|
|
@ -61,6 +61,11 @@ func (hc *HeaderClient) Do(req *http.Request) (*http.Response, error) {
|
|||
req.Header.Add(key, v)
|
||||
}
|
||||
}
|
||||
|
||||
// Use default user agent if none is set
|
||||
if userAgent := hc.Header.Get("User-Agent"); userAgent == "" {
|
||||
req.Header.Add("User-Agent", "csaf-distribution/"+SemVersion)
|
||||
}
|
||||
return hc.Client.Do(req)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue