Skip to content

Commit

Permalink
HTTP spec states when If-Not-Match fails we cannot respond with 304
Browse files Browse the repository at this point in the history
  • Loading branch information
tj committed Sep 13, 2010
1 parent 9998b93 commit adbd971
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions lib/connect/middleware/staticProvider.js
Expand Up @@ -154,6 +154,15 @@ function modified(req, headers) {
noneMatch = req.headers['if-none-match'],
etag = headers['ETag'];

// Check If-None-Match
if (noneMatch && etag) {
var etags = etag.split(/ *, */);
for (var i = 0, len = etags.length; i < len; ++i) {
if (etags[i] == etag) return false;
}
return true;
}

// Check If-Modified-Since
if (modifiedSince && lastModified) {
modifiedSince = new Date(modifiedSince);
Expand All @@ -163,14 +172,6 @@ function modified(req, headers) {
if (lastModified <= modifiedSince) return false;
}
}

// Check If-None-Match
if (noneMatch && etag) {
var etags = etag.split(/ *, */);
for (var i = 0, len = etags.length; i < len; ++i) {
if (etags[i] == etag) return false;
}
}

return true;
}
Expand Down

0 comments on commit adbd971

Please sign in to comment.