Delegate Content-Type verification solely to contentTypeMatches()

Some customer-proxied files have been hosted on servers that will kick back errors if we a) provide a list of Accept'ed Content-Types, or b) provide a Content-Type in the Accept list that the server does not know about.
This commit is contained in:
Blake Stoddard 2020-10-16 11:15:32 -04:00
parent c08b3c505a
commit 65d30640c6

View file

@ -180,12 +180,10 @@ func (p *Proxy) serveImage(w http.ResponseWriter, r *http.Request) {
req.Options.ScaleUp = p.ScaleUp req.Options.ScaleUp = p.ScaleUp
actualReq, _ := http.NewRequest("GET", req.String(), nil) actualReq, _ := http.NewRequest("GET", req.String(), nil)
actualReq.Header.Set("Accept", "*/*")
if p.UserAgent != "" { if p.UserAgent != "" {
actualReq.Header.Set("User-Agent", p.UserAgent) actualReq.Header.Set("User-Agent", p.UserAgent)
} }
if len(p.ContentTypes) != 0 {
actualReq.Header.Set("Accept", strings.Join(p.ContentTypes, ", "))
}
if p.IncludeReferer { if p.IncludeReferer {
// pass along the referer header from the original request // pass along the referer header from the original request
copyHeader(actualReq.Header, r.Header, "referer") copyHeader(actualReq.Header, r.Header, "referer")