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

Fix interpretation of Last-Modified and If-Modified-Since headers

If the dates in `Last-Modified` and `If-Modified-Since` are an exact
match, the server should 304.
This commit is contained in:
James Reggio 2017-08-30 16:10:28 -04:00 committed by Will Norris
parent 50c30f1f85
commit ebcfb52f3a
2 changed files with 7 additions and 2 deletions

View file

@ -275,7 +275,7 @@ func should304(req *http.Request, resp *http.Response) bool {
if err != nil {
return false
}
if lastModified.Before(ifModSince) {
if lastModified.Before(ifModSince) || lastModified.Equal(ifModSince) {
return true
}

View file

@ -223,11 +223,16 @@ func TestShould304(t *testing.T) {
"HTTP/1.1 200 OK\nEtag: \"v\"\n\n",
true,
},
{ // last-modified match
{ // last-modified before
"GET / HTTP/1.1\nIf-Modified-Since: Sun, 02 Jan 2000 00:00:00 GMT\n\n",
"HTTP/1.1 200 OK\nLast-Modified: Sat, 01 Jan 2000 00:00:00 GMT\n\n",
true,
},
{ // last-modified match
"GET / HTTP/1.1\nIf-Modified-Since: Sat, 01 Jan 2000 00:00:00 GMT\n\n",
"HTTP/1.1 200 OK\nLast-Modified: Sat, 01 Jan 2000 00:00:00 GMT\n\n",
true,
},
// mismatches
{