From 396afb8a87451af639773c5a8ee6b6c4da6afb6d Mon Sep 17 00:00:00 2001 From: Will Norris Date: Fri, 15 May 2015 22:27:44 -0700 Subject: [PATCH] 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 --- imageproxy.go | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/imageproxy.go b/imageproxy.go index eda0ec2..ee000da 100644 --- a/imageproxy.go +++ b/imageproxy.go @@ -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) }