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

rename check304 to should304

this reads a little better in if blocks
This commit is contained in:
Will Norris 2017-06-14 16:34:31 -04:00
parent fb63cbe9df
commit c81621ae35
2 changed files with 6 additions and 6 deletions

View file

@ -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

View file

@ -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)
}
}
}