Fixed bug in static file server timestamp comparision before sending back a 304 Not Modified. Only compare upto seconds.

This commit is contained in:
Veebs 2011-10-13 16:54:08 +11:00
parent f8b96fe6b8
commit 7057c59f3d

View File

@ -142,8 +142,11 @@ public class HttpStaticFileServerHandler extends SimpleChannelUpstreamHandler {
{
SimpleDateFormat dateFormatter = new SimpleDateFormat(HTTP_DATE_FORMAT, Locale.US);
Date ifModifiedSinceDate = dateFormatter.parse(ifModifiedSince);
if (ifModifiedSinceDate.getTime() == file.lastModified())
{
// Only compare up to the second because the datetime format we send to the client does not have milliseconds
long ifModifiedSinceDateSeconds = ifModifiedSinceDate.getTime() / 1000;
long fileLastModifiedSeconds = file.lastModified() / 1000;
if (ifModifiedSinceDateSeconds == fileLastModifiedSeconds) {
sendNotModified(ctx);
return;
}