# HG changeset patch # User jbe # Date 1434415774 -7200 # Node ID 32d7423a6753c74159a9d0c90b967d1e6c6bcb1d # Parent 4d5cf5cacc68c5ea7d1dbf46e5049103651e9f3b Removed "prepare" state and added 100-Continue header in local prepare() function in HTTP module diff -r 4d5cf5cacc68 -r 32d7423a6753 moonbridge_http.lua --- a/moonbridge_http.lua Tue Jun 16 00:55:10 2015 +0200 +++ b/moonbridge_http.lua Tue Jun 16 02:49:34 2015 +0200 @@ -338,7 +338,6 @@ -- local variables to track the state: local state = "init" -- one of: -- "init" (initial state) - -- "prepare" (configureation in preparation) -- "no_status_sent" (configuration complete) -- "info_status_sent" (1xx status code has been sent) -- "bodyless_status_sent" (204/304 status code has been sent) @@ -413,7 +412,6 @@ end if state == "init" or - state == "prepare" or state == "no_status_sent" or state == "info_status_sent" then @@ -513,14 +511,15 @@ -- function to prepare (or skip) body processing: local function prepare() assert_not_faulty() - if state == "prepare" then - error("Unexpected internal status in HTTP engine (recursive prepare)") - elseif state ~= "init" then + if state ~= "init" then return end - state = "prepare" - -- TODO + consume = coroutine.wrap(read_body) state = "no_status_sent" + if request.headers_flags["Expect"]["100-continue"] then + request:send_status("100 Continue") + request:finish_headers() + end end -- method to ignore input and close connection after response: function request:monologue() @@ -535,7 +534,7 @@ state = "faulty" consume = drain close_requested = true - if old_state == "init" or old_state == "prepare" then -- TODO: ok? + if old_state == "init" then state = "no_status_sent" else state = old_state @@ -571,11 +570,7 @@ -- (key and value must be provided as separate args) function request:send_header(key, value) assert_not_faulty() - if - state == "init" or - state == "prepare" or - state == "no_status_sent" - then + if state == "init" or state == "no_status_sent" then error("HTTP status has not been sent yet") elseif state == "headers_sent" or