Skip to content

Conversation

aidvu
Copy link

@aidvu aidvu commented Jan 25, 2023

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 a Content-Length for the request body, or specify Transfer-Encoding: chunked and 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.

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. using get_client_body_reader(65536, ngx.req.socket(true)) and using it to proxy the chunked body elsewhere.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant