lua-resty-http
lua-resty-http copied to clipboard
Add support for chunked body to `_send_body`
When trying to send a chunked body, but the function has non-chunked data allow _send_body to properly send chunks w/o modifying the streaming function.
e.g.
local rs, err = ngx.req.socket(true)
local client_body_reader, err = httpc:get_client_body_reader(65535, rs)
local put_res, err = httpc:request_uri(
response["path"],
{
method = "PUT",
headers = headers,
body = client_body_reader,
is_body_function_chunked = true
}
)
I've also seen the comment:
body: The request body as a string, a table of strings, or an iterator function yielding strings until nil when exhausted. Note that you must specify aContent-Lengthfor the request body, or specifyTransfer-Encoding: chunkedand have your function implement the encoding. See also: get_client_body_reader).
I guess another way would be to wrap the returned body reader in a function and handle it in the wrapper or a parameter for _chunked_body_reader to not unchunk the body, but felt like the library should have support for it.