Hello,
Currently, the only API to pass a request body to the ngx.location.capture is to pass the entire request body as a Lua string in the options dictionary.
This means that if the main request needs to pass its own request body to the subrqeuest, it should first read the entire request body to the memory (using the various API the Lua module offers), and then pass it as an argument for ngx.location.catpure.
I want to write a patch that enables the main request to pass its body to the subrequest transparently, meaning without reading it first.
The API should be rather simple, first of all, it means that the main request shouldn't read the body at all and that the lua_need_request_body directive should be set to "off". Then, the API would look something like that:
result = ngx.location.capture("subrequest_location", {parent_request_body = true}).
Does anyone have any suggestions regarding how such a patch can be implemented?
I started off by not setting the subrequest's headers_in.content_len to zero when no body is given if the "parent_request_body" parameter is set to True), but setting it to the correct content length, but this works partially (meaning that only some of the request body is read or none at all).
Best Regards