调用关系太复杂了,每个函数里面都做了很多事情,详细的过程有空再写。
// 当前连接过来时:ngx_http_init_connection会被调用
ngx_http_init_connection->ngx_http_init_request->ngx_http_process_request_line->
ngx_http_process_request_headers->ngx_http_process_request->ngx_http_handler->
ngx_http_core_run_phases->ngx_http_core_find_config_phase(会更新content handler)->
ngx_http_core_content_phase->handler->(会调用两个来完成请求ngx_http_send_header与ngx_http_output_filter)
// 发送响应头注意,最后一个ngx_http_header_filter会调用ngx_http_write_filter来完成响应头的发送
ngx_http_send_header->ngx_http_top_header_filter->***我们的fileter***->ngx_http_header_filter->
ngx_http_write_filter->ngx_send_chain(send_chain)即ngx_writev_chain
// 发送响应体
ngx_http_output_filter->****我们的filter****->ngx_http_write_filter->ngx_send_chain(send_chain)即ngx_writev_chain