Skip to content
Snippets Groups Projects
Commit 99dc590e authored by Frédéric Guillot's avatar Frédéric Guillot
Browse files

Change user agent to bypass some website restrictions

parent 18f55d15
No related branches found
No related tags found
No related merge requests found
......@@ -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)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment