Klaus Demo nginx / 5274f02
Upstream: no last buffer on errors. Previously, after sending a header we always sent a last buffer and finalized a request with code 0, even in case of errors. In some cases this resulted in a loss of ability to detect the response wasn't complete (e.g. if Content-Length was removed from a response by gzip filter). This change tries to propogate to a client information that a response isn't complete in such cases. In particular, with this change we no longer pretend a returned response is complete if we wasn't able to create a temporary file. If an error code suggests the error wasn't fatal, we flush buffered data and disable keepalive, then finalize request normally. This allows to to propogate information about a problem to a client, while still sending all the data we've got from an upstream. Maxim Dounin 8 years ago
1 changed file(s) with 10 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
32963296 ngx_http_upstream_finalize_request(ngx_http_request_t *r,
32973297 ngx_http_upstream_t *u, ngx_int_t rc)
32983298 {
3299 ngx_uint_t flush;
32993300 ngx_time_t *tp;
33003301
33013302 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
34163417 return;
34173418 }
34183419
3419 if (rc == NGX_ERROR || rc >= NGX_HTTP_SPECIAL_RESPONSE) {
3420 rc = 0;
3420 flush = 0;
3421
3422 if (rc >= NGX_HTTP_SPECIAL_RESPONSE) {
3423 rc = NGX_ERROR;
3424 flush = 1;
34213425 }
34223426
34233427 if (r->header_only) {
34273431
34283432 if (rc == 0) {
34293433 rc = ngx_http_send_special(r, NGX_HTTP_LAST);
3434
3435 } else if (flush) {
3436 r->keepalive = 0;
3437 rc = ngx_http_send_special(r, NGX_HTTP_FLUSH);
34303438 }
34313439
34323440 ngx_http_finalize_request(r, rc);