moonbridge

changeset 198:6927f8897f71

Avoid hang-up on empty/nonexistent body in moonbridge_http.lua
author jbe
date Sat Jun 20 01:08:06 2015 +0200 (2015-06-20)
parents efd1b4cfd2e9
children 198b85b736fc
files moonbridge_http.lua
line diff
     1.1 --- a/moonbridge_http.lua	Sat Jun 20 00:46:19 2015 +0200
     1.2 +++ b/moonbridge_http.lua	Sat Jun 20 01:08:06 2015 +0200
     1.3 @@ -502,6 +502,7 @@
     1.4        -- coroutine for request body processing:
     1.5        local function read_body()
     1.6          if request.headers_flags["Transfer-Encoding"]["chunked"] then
     1.7 +          coroutine.yield()  -- do not read on first invocation
     1.8            local limit = body_size_limit
     1.9            while true do
    1.10              local line = read(32 + limit, "\n")
    1.11 @@ -536,6 +537,7 @@
    1.12              end
    1.13            end
    1.14          elseif request_body_content_length then
    1.15 +          coroutine.yield()  -- do not read on first invocation
    1.16            read_body_bytes(request_body_content_length)
    1.17          end
    1.18          if process_body_chunk then
    1.19 @@ -723,6 +725,7 @@
    1.20            return
    1.21          end
    1.22          consume = coroutine.wrap(read_body)
    1.23 +        consume()  -- call coroutine once to avoid hangup on empty body
    1.24          state = "no_status_sent"
    1.25          if request.headers_flags["Expect"]["100-continue"] then
    1.26            request:send_status("100 Continue")

Impressum / About Us