Browse files

Merge pull request #60 from marijnh/if-unmodified-since

Fix handling of if-unmodified-since headers
  • Loading branch information...
2 parents 7f8cc6b + 987665d commit 79eeadd6ca47be27371d832e2edcbea90e2d61c9 @mikedeboer committed Nov 5, 2012
Showing with 24 additions and 22 deletions.
  1. +24 −22 lib/DAV/handler.js
View
46 lib/DAV/handler.js
@@ -1339,7 +1339,7 @@ exports.NS_AJAXORG = "http://ajax.org/2005/aml";
}
}
else {
- cbprecond(null, false);
+ afterIfNoneMatch();
}
function afterIfNoneMatch() {
@@ -1357,17 +1357,18 @@ exports.NS_AJAXORG = "http://ajax.org/2005/aml";
if (!Util.empty(err))
return cbprecond(err);
node = n;
- lastMod = node.getLastModified();
- if (lastMod) {
- lastMod = new Date("@" + lastMod);
- if (lastMod <= date) {
- self.httpResponse.writeHead(304);
- self.httpResponse.end();
- cbprecond(null, true);
- // @todo call cbprecond() differently here?
+ node.getLastModified(function(err, lastMod) {
+ if (lastMod) {
+ lastMod = new Date("@" + lastMod);
+ if (lastMod <= date) {
+ self.httpResponse.writeHead(304);
+ self.httpResponse.end();
+ cbprecond(null, true);
+ // @todo call cbprecond() differently here?
+ }
}
- }
- afterIfModifiedSince();
+ afterIfModifiedSince();
+ });
});
}
else {
@@ -1396,18 +1397,19 @@ exports.NS_AJAXORG = "http://ajax.org/2005/aml";
}
function finale() {
- lastMod = node.getLastModified();
- if (lastMod) {
- lastMod = new Date("@" + lastMod);
- if (lastMod > date) {
- return cbprecond(Exc.jsDAV_Exception_PreconditionFailed(
- "An If-Unmodified-Since header was specified, but the "
- + "entity has been changed since the specified date.",
- "If-Unmodified-Since")
- );
+ node.getLastModified(function(err, lastMod) {
+ if (lastMod) {
+ lastMod = new Date("@" + lastMod);
+ if (lastMod > date) {
+ return cbprecond(new Exc.jsDAV_Exception_PreconditionFailed(
+ "An If-Unmodified-Since header was specified, but the "
+ + "entity has been changed since the specified date.",
+ "If-Unmodified-Since")
+ );
+ }
}
- }
- cbprecond(null, false);
+ cbprecond(null, false);
+ });
}
}
}

0 comments on commit 79eeadd

Please sign in to comment.