Hello!
> I want to get the size (length) of request header , request body , response header and response body! I need to know the main size of original data (not my generated header) how can I do that?
> I think if we have req or resp body, we can get the size of req or resp body using ngx.req.get_headers()["Content-Length"] or ngx.resp.get_headers()["Content-Length"]
> but I have no Idea for getting the size of headers using nginx methods!
For the part of request headers and request body, you can use the variable $request_length from ngx.var.request_length.
For the part of response headers, there is no direct way, you may estimate the size by adding the delimiter, the colon yourself. But some other nginx modules may add their headers, so whether it is exact is depending on the phase that you implement it, for example, you can calculate this in the log phase, I think it is a good phase :).