From c81621ae35df359bcba2d854111f118d3ebb773e Mon Sep 17 00:00:00 2001 From: Will Norris Date: Wed, 14 Jun 2017 16:34:31 -0400 Subject: [PATCH] rename check304 to should304 this reads a little better in if blocks --- imageproxy.go | 6 +++--- imageproxy_test.go | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/imageproxy.go b/imageproxy.go index fee43cd..ac6b357 100644 --- a/imageproxy.go +++ b/imageproxy.go @@ -148,7 +148,7 @@ func (p *Proxy) serveImage(w http.ResponseWriter, r *http.Request) { copyHeader(w, resp, "Etag") copyHeader(w, resp, "Link") - if is304 := check304(r, resp); is304 { + if should304(r, resp) { w.WriteHeader(http.StatusNotModified) return } @@ -233,10 +233,10 @@ func validSignature(key []byte, r *Request) bool { return hmac.Equal(got, want) } -// check304 checks whether we should send a 304 Not Modified in response to +// should304 returns whether we should send a 304 Not Modified in response to // req, based on the response resp. This is determined using the last modified // time and the entity tag of resp. -func check304(req *http.Request, resp *http.Response) bool { +func should304(req *http.Request, resp *http.Response) bool { // TODO(willnorris): if-none-match header can be a comma separated list // of multiple tags to be matched, or the special value "*" which // matches all etags diff --git a/imageproxy_test.go b/imageproxy_test.go index f613153..425059e 100644 --- a/imageproxy_test.go +++ b/imageproxy_test.go @@ -145,7 +145,7 @@ func TestValidSignature(t *testing.T) { } } -func TestCheck304(t *testing.T) { +func TestShould304(t *testing.T) { tests := []struct { req, resp string is304 bool @@ -212,8 +212,8 @@ func TestCheck304(t *testing.T) { t.Errorf("http.ReadResponse(%q) returned error: %v", tt.resp, err) } - if got, want := check304(req, resp), tt.is304; got != want { - t.Errorf("check304(%q, %q) returned: %v, want %v", tt.req, tt.resp, got, want) + if got, want := should304(req, resp), tt.is304; got != want { + t.Errorf("should304(%q, %q) returned: %v, want %v", tt.req, tt.resp, got, want) } } }