The Calling relationship is too complicated. Every function has done a lot of things, and the detailed process is free to write.
// When the current connection is over: ngx_http_init_connection will be called
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 will be updated)->
Ngx_http_core_content_phase-> Handler-> (two requests are called to complete ngx_http_send_header and ngx_http_output_filter)
// Send the response header. The last ngx_http_header_filter will call ngx_http_write_filter to send the response header.
Ngx_http_send_header-> ngx_http_top_header_filter-> *** our fileter ***-> ngx_http_header_filter->
Ngx_http_write_filter-> ngx_send_chain (send_chain) is ngx_writev_chain
// Send the response body
Ngx_http_output_filter-> ***** our filter *****-> ngx_http_write_filter-> ngx_send_chain (send_chain) is ngx_writev_chain
Each stage may have multiple handler, which are stored in phase_engine. The classification and storage in phase are saved in sequence. The call parsing for one stage and one stage is called: ngx_http_core_generic_phasehandler, which corresponds to each handler in phase. Next: point to the next phase, that is, Handler: corresponds to each handler in phase next: points to the next phase, that is, Handler: No next: No ngx_http_rewrite_phasechecker: ngx_http_core_generic_phasehandler: next corresponds to each handler in phase: pointing to the next phase, that is, handler (if rewrite is used) Checker: Handler: None next: pointing to handler: ngx_http_core_generic_phasehandler: corresponding to next for each handler in phase: point to the next phase, that is, handler (N adds one more) Checker: ngx_http_core_access_phasehandler: corresponds to each handler in phase next: points to the next phase, that is, ngx_http_try_files_phase) ngx_http_post_access_phase (if access is used) Checker: marker: No next: points to the next phase, that is, Handler: Failed: No next: No ngx_http_content_phasechecker: Next: corresponds to each handler in phase: point to the next phase, that is, ngx_http_log_phasengx_http_log_phasechecker: ngx_http_core_generic_phasehandler: Next to each handler in the phase, pointing to the next phase, null