summaryrefslogtreecommitdiffhomepage
path: root/libs/http
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2008-06-28 16:12:37 +0000
committerJo-Philipp Wich <jow@openwrt.org>2008-06-28 16:12:37 +0000
commite08b97565f2a2dfeb482be0f061bfefa93d32556 (patch)
treec9de80c79c6de3da952fe9a2ca07559884aa3f67 /libs/http
parent00aceaf624d8e5da2a8f3df161d52599aae2ac41 (diff)
* libs/http: fix header handling in conditionals.lua
* libs/httpd: add support for RFC2616 / 14.24 - 14.28 in file handler, add Date and Expires headers to luci handler
Diffstat (limited to 'libs/http')
-rw-r--r--libs/http/luasrc/http/protocol.lua6
-rw-r--r--libs/http/luasrc/http/protocol/conditionals.lua15
2 files changed, 13 insertions, 8 deletions
diff --git a/libs/http/luasrc/http/protocol.lua b/libs/http/luasrc/http/protocol.lua
index 205869a2d..67b425857 100644
--- a/libs/http/luasrc/http/protocol.lua
+++ b/libs/http/luasrc/http/protocol.lua
@@ -160,7 +160,7 @@ process_states['magic'] = function( msg, chunk, err )
end
end
end
-
+
-- Can't handle it
return nil, "Invalid HTTP message magic"
end
@@ -533,7 +533,7 @@ function header_source( sock )
local chunk, err, part = sock:receive("*l")
-- Line too long
- if chunk == nil then
+ if chunk == nil then
if err ~= "timeout" then
return nil, part
and "Line exceeds maximum allowed length["..part.."]"
@@ -779,11 +779,13 @@ end
-- Status codes
statusmsg = {
[200] = "OK",
+ [304] = "Not Modified",
[400] = "Bad Request",
[403] = "Forbidden",
[404] = "Not Found",
[405] = "Method Not Allowed",
[411] = "Length Required",
+ [412] = "Precondition Failed",
[500] = "Internal Server Error",
[503] = "Server Unavailable",
}
diff --git a/libs/http/luasrc/http/protocol/conditionals.lua b/libs/http/luasrc/http/protocol/conditionals.lua
index 0bff274cd..36f323a6e 100644
--- a/libs/http/luasrc/http/protocol/conditionals.lua
+++ b/libs/http/luasrc/http/protocol/conditionals.lua
@@ -21,7 +21,7 @@ local date = require("luci.http.protocol.date")
-- 14.19 / ETag
function mk_etag( stat )
if stat ~= nil then
- return string.format( "%x-%x-%x", stat.ino, stat.size, stat.mtime )
+ return string.format( '"%x-%x-%x"', stat.ino, stat.size, stat.mtime )
end
end
@@ -56,7 +56,10 @@ function if_modified_since( req, stat )
return true
end
- return false, 304
+ return false, 304, {
+ ["ETag"] = mk_etag( stat );
+ ["Last-Modified"] = date.to_http( stat.mtime )
+ }
end
return true
@@ -74,10 +77,10 @@ function if_none_match( req, stat )
if req.request_method == "get" or
req.request_method == "head"
then
- h['ETag'] = mk_etag( stat )
- h['Last-Modified'] = date.to_http( stat.mtime )
-
- return false, 304
+ return false, 304, {
+ ["ETag"] = mk_etag( stat );
+ ["Last-Modified"] = date.to_http( stat.mtime )
+ }
else
return false, 412
end