luci-0.9: merge r5635
authorJo-Philipp Wich <jow@openwrt.org>
Sun, 20 Dec 2009 18:19:18 +0000 (18:19 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Sun, 20 Dec 2009 18:19:18 +0000 (18:19 +0000)
libs/http/luasrc/http/protocol/conditionals.lua

index 015cf4518b40de49226661e7dd99e9d3d43ffe19..635d6b2db006a20577b8f5689c162db89ca76c16 100644 (file)
@@ -93,16 +93,15 @@ end
 -- @return             Alternative status code if the precondition failed
 -- @return             Table containing extra HTTP headers if the precondition failed
 function if_none_match( req, stat )
-       local h    = req.headers
-       local etag = mk_etag( stat )
+       local h      = req.headers
+       local etag   = mk_etag( stat )
+       local method = req.env and req.env.REQUEST_METHOD or "GET"
 
        -- Check for matching resource
        if type(h['If-None-Match']) == "string" then
                for ent in h['If-None-Match']:gmatch("([^, ]+)") do
                        if ( ent == '*' or ent == etag ) and stat ~= nil then
-                               if req.request_method == "get"  or
-                                  req.request_method == "head"
-                               then
+                               if method == "GET" or method == "HEAD" then
                                        return false, 304, {
                                                ["ETag"]          = mk_etag( stat );
                                                ["Date"]          = date.to_http( os.time() );