Omit User-Agent header in image proxy to avoid being blocked

This commit is contained in:
Frédéric Guillot 2022-01-09 20:18:08 -08:00
parent 2309b27458
commit b113af8472
1 changed files with 3 additions and 2 deletions

View File

@ -45,7 +45,8 @@ func (h *handler) imageProxy(w http.ResponseWriter, r *http.Request) {
html.ServerError(w, r, err)
return
}
req.Header.Add("User-Agent", config.Opts.HTTPClientUserAgent())
// Note: User-Agent HTTP header is omitted to avoid being blocked by bot protection mechanisms.
req.Header.Add("Connection", "close")
clt := &http.Client{
@ -60,7 +61,7 @@ func (h *handler) imageProxy(w http.ResponseWriter, r *http.Request) {
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
logger.Error(`[Proxy] code=%d url=%q`, resp.StatusCode, imageURL)
logger.Error(`[Proxy] Status Code is %d for URL %q`, resp.StatusCode, imageURL)
html.NotFound(w, r)
return
}