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:
parent
50c30f1f85
commit
ebcfb52f3a
2 changed files with 7 additions and 2 deletions
|
@ -275,7 +275,7 @@ func should304(req *http.Request, resp *http.Response) bool {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if lastModified.Before(ifModSince) {
|
if lastModified.Before(ifModSince) || lastModified.Equal(ifModSince) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -223,11 +223,16 @@ func TestShould304(t *testing.T) {
|
||||||
"HTTP/1.1 200 OK\nEtag: \"v\"\n\n",
|
"HTTP/1.1 200 OK\nEtag: \"v\"\n\n",
|
||||||
true,
|
true,
|
||||||
},
|
},
|
||||||
{ // last-modified match
|
{ // last-modified before
|
||||||
"GET / HTTP/1.1\nIf-Modified-Since: Sun, 02 Jan 2000 00:00:00 GMT\n\n",
|
"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",
|
"HTTP/1.1 200 OK\nLast-Modified: Sat, 01 Jan 2000 00:00:00 GMT\n\n",
|
||||||
true,
|
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
|
// mismatches
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue