moonbridge

diff moonbridge_http.lua @ 171:32d7423a6753

Removed "prepare" state and added 100-Continue header in local prepare() function in HTTP module
author jbe
date Tue Jun 16 02:49:34 2015 +0200 (2015-06-16)
parents 4d5cf5cacc68
children fb54c76e1484
line diff
     1.1 --- a/moonbridge_http.lua	Tue Jun 16 00:55:10 2015 +0200
     1.2 +++ b/moonbridge_http.lua	Tue Jun 16 02:49:34 2015 +0200
     1.3 @@ -338,7 +338,6 @@
     1.4        -- local variables to track the state:
     1.5        local state = "init"        -- one of:
     1.6        --  "init"                  (initial state)
     1.7 -      --  "prepare"               (configureation in preparation)
     1.8        --  "no_status_sent"        (configuration complete)
     1.9        --  "info_status_sent"      (1xx status code has been sent)
    1.10        --  "bodyless_status_sent"  (204/304 status code has been sent)
    1.11 @@ -413,7 +412,6 @@
    1.12          end
    1.13          if
    1.14            state == "init" or
    1.15 -          state == "prepare" or
    1.16            state == "no_status_sent" or
    1.17            state == "info_status_sent"
    1.18          then
    1.19 @@ -513,14 +511,15 @@
    1.20        -- function to prepare (or skip) body processing:
    1.21        local function prepare()
    1.22          assert_not_faulty()
    1.23 -        if state == "prepare" then
    1.24 -          error("Unexpected internal status in HTTP engine (recursive prepare)")
    1.25 -        elseif state ~= "init" then
    1.26 +        if state ~= "init" then
    1.27            return
    1.28          end
    1.29 -        state = "prepare"
    1.30 -        -- TODO
    1.31 +        consume = coroutine.wrap(read_body)
    1.32          state = "no_status_sent"
    1.33 +        if request.headers_flags["Expect"]["100-continue"] then
    1.34 +          request:send_status("100 Continue")
    1.35 +          request:finish_headers()
    1.36 +        end
    1.37        end
    1.38        -- method to ignore input and close connection after response:
    1.39        function request:monologue()
    1.40 @@ -535,7 +534,7 @@
    1.41          state = "faulty"
    1.42          consume = drain
    1.43          close_requested = true
    1.44 -        if old_state == "init" or old_state == "prepare" then  -- TODO: ok?
    1.45 +        if old_state == "init" then
    1.46            state = "no_status_sent"
    1.47          else
    1.48            state = old_state
    1.49 @@ -571,11 +570,7 @@
    1.50        -- (key and value must be provided as separate args)
    1.51        function request:send_header(key, value)
    1.52          assert_not_faulty()
    1.53 -        if
    1.54 -          state == "init" or
    1.55 -          state == "prepare" or
    1.56 -          state == "no_status_sent"
    1.57 -        then
    1.58 +        if state == "init" or state == "no_status_sent" then
    1.59            error("HTTP status has not been sent yet")
    1.60          elseif
    1.61            state == "headers_sent" or

Impressum / About Us