Open amreladawy opened 8 years ago
You could use ngx.location.capture which is synchronous , when it returns you can get the body length: local len = #(res.body) ngx.header["Content-Length"] = len howerver there may be a out of memory problem when the upstream respone body is too large, in my case it is less than 1KB (hls live m3u8)
Hi, Did you find another solution for this issue? (without using ngx.location.capture) Thanks
bump. is there any solution or over around for this ? Basically need to set headers based on response body from proxied upstream.
Hi @Prasanna-sr , i need to do the same thing, could you solve that? thanks.
@luksbelt i ended up using "ngx.location.capture" as a work around for this
Hi, Is there any solution for this?
I am reopening this because I did not get a clear answer on my previous issue raised https://github.com/openresty/lua-nginx-module/issues/888
I am using openresty as a reverse proxy between a client and a service provider through the following steps
I am changing the headers coming from the client I convert the GET method to POST and create a body to be passed to the proxied server. The response coming back from the proxied server is then altered and sent to the client
The problem
As the final response sent back to the client is altered, I need to change the
Content-Length
to match the new content. I am able to read the response from the proxied server only in thebody_filter_by_lua_file
but at that stage, the headers are already sent.In the
header_filter_by_lua_file
phase, I don't have access on the responsengx.args[1]
Currently, I am removing the
Content-Length
header making the response chunked which is causing a problem the client.How can I send the correct content length back to the client?