0
Fork 0
mirror of https://github.com/willnorris/imageproxy.git synced 2024-12-16 21:56:43 -05:00

proxy non-200 responses with original status code

Some sites return a 404 image, and most browsers render them properly.
We should pass them along as well.

see also: atmos/camo#75 and atmos/camo#77
This commit is contained in:
Will Norris 2015-05-15 22:27:44 -07:00
parent bdf995c94f
commit 396afb8a87

View file

@ -113,13 +113,6 @@ func (p *Proxy) ServeHTTP(w http.ResponseWriter, r *http.Request) {
cached := resp.Header.Get(httpcache.XFromCache)
glog.Infof("request: %v (served from cache: %v)", *req, cached == "1")
if resp.StatusCode != http.StatusOK {
msg := fmt.Sprintf("remote URL %q returned status: %v", req.URL, resp.Status)
glog.Error(msg)
http.Error(w, msg, resp.StatusCode)
return
}
copyHeader(w, resp, "Last-Modified")
copyHeader(w, resp, "Expires")
copyHeader(w, resp, "Etag")
@ -131,6 +124,7 @@ func (p *Proxy) ServeHTTP(w http.ResponseWriter, r *http.Request) {
copyHeader(w, resp, "Content-Length")
copyHeader(w, resp, "Content-Type")
w.WriteHeader(resp.StatusCode)
io.Copy(w, resp.Body)
}