ngx_buf_t describes a block of response data through metadata and pointers. Allocate it from the request’s NGINX memory pool, then configure its handling flags before sending the response. section 4.6
Building a response buffer
Allocate storage with ngx_pcalloc, copy the response bytes into it, assign buf.pos and buf.last, wrap the buffer in ngx_chain_t, and pass the chain to ngx_http_output_filter.
