Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for chunked body to _send_body #285

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant