Index: http.lua =================================================================== --- http.lua (revision 15069) +++ http.lua (working copy) @@ -648,7 +648,7 @@ response_raw = "" while recv_status do recv_status, response_tmp = socket:receive() - response_raw = response_raw .. response_tmp + if recv_status then response_raw = response_raw .. response_tmp end end -- Transform the raw response we received in a table of responses and @@ -829,12 +829,14 @@ -- handle chunked encoding if result.header['transfer-encoding'] == 'chunked' then - local _, chunk - local chunks = {} - for _, chunk in get_chunks(body, 1, body_delim) do - chunks[#chunks + 1] = chunk + if not body == body_delim then + local _, chunk + local chunks = {} + for _, chunk in get_chunks(body, 1, body_delim) do + chunks[#chunks + 1] = chunk + end + body = table.concat(chunks) end - body = table.concat(chunks) end -- special case for conjoined header and body