Fix if-modified-since test bug

This commit is contained in:
Neale Pickett 2012-03-13 20:54:22 -06:00
parent a2179d8453
commit 7995aed5bb
2 changed files with 5 additions and 1 deletions

2
eris.c
View File

@ -319,7 +319,7 @@ serve_file(int fd, char *filename, struct stat *st)
badrequest(405, "Method Not Supported", "POST is not supported by this URL");
}
if (st->st_mtime < ims) {
if (st->st_mtime <= ims) {
header(304, "Not Changed");
eoh();
return;

View File

@ -130,6 +130,10 @@ H "If-Modified-Since"
title "Has been modified"
printf 'GET / HTTP/1.0\r\nIf-Modified-Since: Sun, 27 Feb 1980 12:12:12 GMT\r\n\r\n' | $HTTPD 2>/dev/null | grep -q 'HTTP/1.. 200 ' && pass || fail
title "Exact same date"
ims=$(printf 'GET / HTTP/1.0\r\n\r\n' | $HTTPD 2>/dev/null | awk -F ': ' '/Last-Modified/ {print $2;}')
printf 'GET / HTTP/1.0\r\nIf-Modified-Since: %s\r\n\r\n' "$ims" | $HTTPD 2>/dev/null | grep -q 'HTTP/1.. 304 ' && pass || fail
title "RFC 822 Date"
printf 'GET / HTTP/1.0\r\nIf-Modified-Since: Sun, 27 Feb 2030 12:12:12 GMT\r\n\r\n' | $HTTPD 2>/dev/null | grep -q 'HTTP/1.. 304 ' && pass || fail