# HG changeset patch # User Roman Arutyunyan # Date 1492616197 -10800 # Node ID 275c928ab386296ee72a0d45b7d7ec6d8ab637ef # Parent 69908bd684811392f875e027a75047681c6db87b The HTTP request finalization section of the development guide. diff -r 69908bd68481 -r 275c928ab386 xml/en/docs/dev/development_guide.xml --- a/xml/en/docs/dev/development_guide.xml Wed Apr 19 18:35:57 2017 +0300 +++ b/xml/en/docs/dev/development_guide.xml Wed Apr 19 18:36:37 2017 +0300 @@ -4985,6 +4985,69 @@ +
+ + +An HTTP request is finalized by calling the function +ngx_http_finalize_request(r, rc). +It is usually finalized by the content handler after sending all output buffers +to the filter chain. +At this point the output may not be completely sent to the client, but remain +buffered somewhere along the filter chain. +If it is, the ngx_http_finalize_request(r, rc) function will +automatically install a special handler ngx_http_writer(r) +to finish sending the output. +A request is also finalized in case of an error or if a standard HTTP response +code needs to be returned to the client. + + + +The function ngx_http_finalize_request(r, rc) expects the +following rc values: + + + + + +NGX_DONE - fast finalization. +Decrement request count and destroy the request if it +reaches zero. +The client connection may still be used for more requests after that + + + +NGX_ERROR, NGX_HTTP_REQUEST_TIME_OUT +(408), NGX_HTTP_CLIENT_CLOSED_REQUEST (499) - error +finalization. +Terminate the request as soon as possible and close the client connection. + + + +NGX_HTTP_CREATED (201), +NGX_HTTP_NO_CONTENT (204), codes greater than or equal to +NGX_HTTP_SPECIAL_RESPONSE (300) - special response +finalization. +For these values nginx either sends a default code response page to the client +or performs the internal redirect to an + location if it's +configured for the code + + + +Other codes are considered success finalization codes and may activate the +request writer to finish sending the response body. +Once body is completely sent, request count is decremented. +If it reaches zero, the request is destroyed, but the client connection may +still be used for other requests. +If count is positive, there are unfinished activities +within the request, which will be finalized at a later point. + + + + +
+ +