Change user agent to bypass some website restrictions
This commit is contained in:
parent
18f55d1569
commit
99dc590e45
1 changed files with 9 additions and 7 deletions
|
@ -15,7 +15,8 @@ import (
|
||||||
"github.com/miniflux/miniflux/logger"
|
"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
|
const requestTimeout = 300
|
||||||
|
|
||||||
// Client is a HTTP Client :)
|
// Client is a HTTP Client :)
|
||||||
|
@ -47,12 +48,12 @@ func (c *Client) Get() (*Response, error) {
|
||||||
ContentType: resp.Header.Get("Content-Type"),
|
ContentType: resp.Header.Get("Content-Type"),
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.Debug("[HttpClient:Get]",
|
logger.Debug("[HttpClient:Get] OriginalURL=%s, StatusCode=%d, ETag=%s, LastModified=%s, EffectiveURL=%s",
|
||||||
"OriginalURL:", c.url,
|
c.url,
|
||||||
"StatusCode:", response.StatusCode,
|
response.StatusCode,
|
||||||
"ETag:", response.ETag,
|
response.ETag,
|
||||||
"LastModified:", response.LastModified,
|
response.LastModified,
|
||||||
"EffectiveURL:", response.EffectiveURL,
|
response.EffectiveURL,
|
||||||
)
|
)
|
||||||
|
|
||||||
return response, err
|
return response, err
|
||||||
|
@ -87,6 +88,7 @@ func (c *Client) buildClient() http.Client {
|
||||||
func (c *Client) buildHeaders() http.Header {
|
func (c *Client) buildHeaders() http.Header {
|
||||||
headers := make(http.Header)
|
headers := make(http.Header)
|
||||||
headers.Add("User-Agent", userAgent)
|
headers.Add("User-Agent", userAgent)
|
||||||
|
headers.Add("Accept", "text/html,application/xhtml+xml,application/xml,application/json")
|
||||||
|
|
||||||
if c.etagHeader != "" {
|
if c.etagHeader != "" {
|
||||||
headers.Add("If-None-Match", c.etagHeader)
|
headers.Add("If-None-Match", c.etagHeader)
|
||||||
|
|
Loading…
Reference in a new issue