daurnimator / lua-http

HTTP Library for Lua. Supports HTTP(S) 1.0, 1.1 and 2.0; client and server.
https://daurnimator.github.io/lua-http/
MIT License
778 stars 80 forks source link

Issue with get_next_chunk() function in get_body_chars() #219

Open obulesu458 opened 5 months ago

obulesu458 commented 5 months ago

Sometines,the get_next_chunk() function and the get_body_chars() function in lua-http stream does not return full body of the request. Currently, when I make a request with a content length of 1.1MB, the get_next_chunk() function only returns 1MB of data. This results in an incomplete body being processed. Due to this in "get_body_chars(n, timeout)", a condition is met where the block size( n ) exceeds the available body size, causing an infinite loop. No error is thrown in this case, and the timeout does not work. below is the Lua pseudo code how did I use :

` function (http_stream)

    return coroutine :

            for chunk in http_stream:get_body_chars():

                    get chunk

                    yield chunk

            end

end

`

but it works as expected and gives all chunks of data when I do the same outside the coroutine. Any reason?