nginx_filter_framework
Overview
nginx supports two kinds of filter when sending response to client, one is header filter, the other is body filter, header filter is called before sending response header to client, body filter is called before sending body to client, you can create your own filter module to do anything(mostly related to header manipulation or body manipulation) without break any nginx source code.
filter framework
As you can see, filter is like chain, the last configured one is called first
, because the last one is the one who sets ngx_http_top_body_filter
and ngx_http_top_header_filter
which are called by ngx_http_output_filter()
and ngx_http_send_header()
.