diff options
author | Frédéric Guillot <fred@miniflux.net> | 2017-12-18 17:59:35 -0800 |
---|---|---|
committer | Frédéric Guillot <fred@miniflux.net> | 2017-12-18 17:59:35 -0800 |
commit | 99dc590e459eb760a3aae963226ff843c2f51917 (patch) | |
tree | b341a56eb28a8499c0fbb3d9c2e91d72f63d39ad /http | |
parent | 18f55d156995371bfb06ca8cd91da5a922d2a937 (diff) |
Change user agent to bypass some website restrictions
Diffstat (limited to 'http')
-rw-r--r-- | http/client.go | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/http/client.go b/http/client.go index 8473826..9524dd6 100644 --- a/http/client.go +++ b/http/client.go @@ -15,7 +15,8 @@ import ( "github.com/miniflux/miniflux/logger" ) -const userAgent = "Miniflux <https://miniflux.net/>" +// Note: Some websites have a user agent filter. +const userAgent = "Mozilla/5.0 (like Gecko, like Safari, like Chrome) - Miniflux <https://miniflux.net/>" const requestTimeout = 300 // Client is a HTTP Client :) @@ -47,12 +48,12 @@ func (c *Client) Get() (*Response, error) { ContentType: resp.Header.Get("Content-Type"), } - logger.Debug("[HttpClient:Get]", - "OriginalURL:", c.url, - "StatusCode:", response.StatusCode, - "ETag:", response.ETag, - "LastModified:", response.LastModified, - "EffectiveURL:", response.EffectiveURL, + logger.Debug("[HttpClient:Get] OriginalURL=%s, StatusCode=%d, ETag=%s, LastModified=%s, EffectiveURL=%s", + c.url, + response.StatusCode, + response.ETag, + response.LastModified, + response.EffectiveURL, ) return response, err @@ -87,6 +88,7 @@ func (c *Client) buildClient() http.Client { func (c *Client) buildHeaders() http.Header { headers := make(http.Header) headers.Add("User-Agent", userAgent) + headers.Add("Accept", "text/html,application/xhtml+xml,application/xml,application/json") if c.etagHeader != "" { headers.Add("If-None-Match", c.etagHeader) |