Closed asxcandrew closed 3 years ago
I'd ran into this myself - I'm happy to have this - I'd personally worked around this as:
type userAgentTransport struct {
http.RoundTripper
}
func (c *userAgentTransport) RoundTrip(r *http.Request) (*http.Response, error) {
r.Header.Set("User-Agent", "cronrunner-rss-reader:1.0.0")
return c.RoundTripper.RoundTrip(r)
}
func parser() *gofeed.Parser {
p := gofeed.NewParser()
p.Client = &http.Client{}
p.Client.Transport = &userAgentTransport{
http.DefaultTransport,
}
return p
}
Seems like one of resources has banned User-Agent "Gofeed/1.0", so I would like to be able to set a custom UserAgent