-- compare it against the given stat object.
-- @param req HTTP request message object
-- @param stat A file.stat object
--- @return Boolean indicating wheather the precondition is ok
+-- @return Boolean indicating whether the precondition is ok
-- @return Alternative status code if the precondition failed
function if_match( req, stat )
local h = req.headers
-- and compare it against the given stat object.
-- @param req HTTP request message object
-- @param stat A file.stat object
--- @return Boolean indicating wheather the precondition is ok
+-- @return Boolean indicating whether the precondition is ok
-- @return Alternative status code if the precondition failed
-- @return Table containing extra HTTP headers if the precondition failed
function if_modified_since( req, stat )
-- compare it against the given stat object.
-- @param req HTTP request message object
-- @param stat A file.stat object
--- @return Boolean indicating wheather the precondition is ok
+-- @return Boolean indicating whether the precondition is ok
-- @return Alternative status code if the precondition failed
-- @return Table containing extra HTTP headers if the precondition failed
function if_none_match( req, stat )
if ( ent == '*' or ent == etag ) and stat ~= nil then
if method == "GET" or method == "HEAD" then
return false, 304, {
- ["ETag"] = mk_etag( stat );
+ ["ETag"] = etag;
["Date"] = date.to_http( os.time() );
["Last-Modified"] = date.to_http( stat.mtime )
}
-- false, 412 to indicate a failed precondition.
-- @param req HTTP request message object
-- @param stat A file.stat object
--- @return Boolean indicating wheather the precondition is ok
+-- @return Boolean indicating whether the precondition is ok
-- @return Alternative status code if the precondition failed
function if_range( req, stat )
-- Sorry, no subranges (yet)
-- header and compare it against the given stat object.
-- @param req HTTP request message object
-- @param stat A file.stat object
--- @return Boolean indicating wheather the precondition is ok
+-- @return Boolean indicating whether the precondition is ok
-- @return Alternative status code if the precondition failed
function if_unmodified_since( req, stat )
local h = req.headers