moonbridge
diff moonbridge_http.lua @ 191:ab12ecb399f1
Signal request body EOF in HTTP module
author | jbe |
---|---|
date | Fri Jun 19 19:35:23 2015 +0200 (2015-06-19) |
parents | a6a704ca86ee |
children | 281f1ac41fc6 |
line diff
1.1 --- a/moonbridge_http.lua Fri Jun 19 19:27:01 2015 +0200 1.2 +++ b/moonbridge_http.lua Fri Jun 19 19:35:23 2015 +0200 1.3 @@ -537,6 +537,9 @@ 1.4 elseif request_body_content_length then 1.5 read_body_bytes(request_body_content_length) 1.6 end 1.7 + if process_body_chunk then 1.8 + process_body_chunk(nil) -- signal EOF 1.9 + end 1.10 consume = nil -- avoid further resumes 1.11 end 1.12 -- function to setup default request body handling: 1.13 @@ -950,10 +953,15 @@ 1.14 error("Cannot setup request body streamer at this stage anymore") 1.15 end 1.16 local inprogress = false 1.17 + local eof = false 1.18 local buffer = {} 1.19 process_body_chunk = function(chunk) 1.20 if inprogress then 1.21 - buffer[#buffer+1] = chunk 1.22 + if chunk == nil then 1.23 + eof = true 1.24 + else 1.25 + buffer[#buffer+1] = chunk 1.26 + end 1.27 else 1.28 inprogress = true 1.29 callback(chunk) 1.30 @@ -962,6 +970,9 @@ 1.31 buffer = {} 1.32 callback(chunk) 1.33 end 1.34 + if eof then 1.35 + callback() -- signal EOF 1.36 + end 1.37 inprogress = false 1.38 end 1.39 end