diff options
author | Steven Barth <steven@midlink.org> | 2008-06-21 16:23:41 +0000 |
---|---|---|
committer | Steven Barth <steven@midlink.org> | 2008-06-21 16:23:41 +0000 |
commit | bfbd74c6ae869467061958c92f18d9cc28079ea5 (patch) | |
tree | fb0adc95f11d5833eeff4d0d317c1141631f17e7 /libs/httpd | |
parent | 65870edf9f1e579b4301e1677d70c9387a9a72dc (diff) |
* libs/httpd: Forward changed Handler API to use luci.http to push responses
* libs/httpd: Added Expect: 100-continue header support to server (merged from Jow)
Diffstat (limited to 'libs/httpd')
-rw-r--r-- | libs/httpd/luasrc/httpd/module.lua | 17 | ||||
-rw-r--r-- | libs/httpd/luasrc/httpd/server.lua | 10 |
2 files changed, 12 insertions, 15 deletions
diff --git a/libs/httpd/luasrc/httpd/module.lua b/libs/httpd/luasrc/httpd/module.lua index 4bf697744..ba745bde3 100644 --- a/libs/httpd/luasrc/httpd/module.lua +++ b/libs/httpd/luasrc/httpd/module.lua @@ -90,20 +90,7 @@ function Handler.process(self, request, sourcein, sinkout, sinkerr) end end - - -- Print status and headers - sinkout("HTTP/1.1 " .. response.status .. " " .. statusmsg[response.status] .. "\r\n") - for k, v in pairs(response.headers) do - sinkout(k .. ": " .. v .. "\r\n") - end - - -- End of Headers - sinkout("\r\n") - - -- Pump content - if sourceout then - ltn12.pump.all(sourceout, sinkout) - end + luci.http.push_response(request, status, response, sourceout, sinkout, sinkerr) end @@ -132,7 +119,7 @@ end -- Handler Response Response = luci.util.class() -function Response.__init__(self, status, headers) +function Response.__init__(self, request, status, headers) self.status = tonumber(status) or 200 self.headers = (type(headers) == "table") and headers or {} end diff --git a/libs/httpd/luasrc/httpd/server.lua b/libs/httpd/luasrc/httpd/server.lua index d54001336..9155e93f5 100644 --- a/libs/httpd/luasrc/httpd/server.lua +++ b/libs/httpd/luasrc/httpd/server.lua @@ -98,6 +98,16 @@ function client_handler(client) local message, err = luci.http.protocol.parse_message_header( line_source ) if message then + + -- If we have a HTTP/1.1 client and an Expect: 100-continue header then + -- respond with HTTP 100 Continue message + if message.http_version == 1.1 and message.headers['Expect'] and + message.headers['Expect'] == '100-continue' + then + client:send("HTTP/1.1 100 Continue\r\n\r\n") + end + + local s, e = luci.http.protocol.parse_message_body( block_source, message ) -- XXX: debug |