If-Modified-Since is busted (incorrect date comparison) #98

Closed
snej opened this Issue Oct 18, 2010 · 1 comment

Projects

None yet

2 participants

@snej
Contributor
snej commented Oct 18, 2010

Current trunk's handling of If-Modified-Since headers is pretty busted — it's not comparing dates correctly. Here's what I ran into:

$ curl -I -H 'If-Modified-Since: Sun, 26 Sep 2010 23:43:52 GMT' 'http://localhost:3001/outbox'
HTTP/1.1 304 Not Modified
Last-Modified: Mon, 18 Oct 2010 20:57:11 GMT
Set-Cookie: rack.session=BAh7AA%3D%3D%0A; path=/
Connection: close
Server: thin 1.2.7 codename No Hup

$ curl -I -H 'If-Modified-Since: Sun, 26 Sep 2010 23:43:52 GMT' 'http://localhost:3001/outbox'
HTTP/1.1 304 Not Modified
Last-Modified: Mon, 18 Oct 2010 20:57:11 GMT
Set-Cookie: rack.session=BAh7AA%3D%3D%0A; path=/
Connection: close
Server: thin 1.2.7 codename No Hup

The bug appears to be in the function last_modified. I added some logging and found that the line starting with "halt 304 if ..." is actually comparing strings, not Time objects. Which explains why it thinks "Oct" comes before "Sep".

@rkh
Member
rkh commented Oct 19, 2010

Use date comparison instead of string comparison for last_modified helper. Closed by 616576c.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment