mirror of
https://github.com/willnorris/imageproxy.git
synced 2024-12-16 21:56:43 -05:00
return early if remote URL returns a 404
This commit is contained in:
parent
1ba0bd0a6d
commit
a9b6594b41
1 changed files with 6 additions and 0 deletions
|
@ -221,6 +221,12 @@ func (p *Proxy) serveImage(w http.ResponseWriter, r *http.Request) {
|
||||||
// close the original resp.Body, even if we wrap it in a NopCloser below
|
// close the original resp.Body, even if we wrap it in a NopCloser below
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
||||||
|
// return early on 404s. Perhaps handle additional status codes here?
|
||||||
|
if resp.StatusCode == http.StatusNotFound {
|
||||||
|
http.Error(w, "not found", http.StatusNotFound)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
cached := resp.Header.Get(httpcache.XFromCache) == "1"
|
cached := resp.Header.Get(httpcache.XFromCache) == "1"
|
||||||
if p.Verbose {
|
if p.Verbose {
|
||||||
p.logf("request: %+v (served from cache: %t)", *actualReq, cached)
|
p.logf("request: %+v (served from cache: %t)", *actualReq, cached)
|
||||||
|
|
Loading…
Reference in a new issue