src/http/ngx_http_upstream.c:718: error: Integer Overflow L2
  ([0, `r->uri_changes`] - 1):unsigned32 by call to `ngx_http_upstream_connect`.

src/http/ngx_http_upstream.c:538:1: Parameter `r->uri_changes`
536. 
537. 
538. static void
     ^
539. ngx_http_upstream_init_request(ngx_http_request_t *r)
540. {

src/http/ngx_http_upstream.c:718:13: Call
716.             }
717. 
718.             ngx_http_upstream_connect(r, u);
                 ^
719. 
720.             return;

src/http/ngx_http_upstream.c:1482:1: Parameter `r->uri_changes`
  1480. 
  1481. 
  1482. static void
        ^
  1483. ngx_http_upstream_connect(ngx_http_request_t *r, ngx_http_upstream_t *u)
  1484. {

src/http/ngx_http_upstream.c:1522:9: Call
  1520.     if (rc == NGX_BUSY) {
  1521.         ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "no live upstreams");
  1522.         ngx_http_upstream_next(r, u, NGX_HTTP_UPSTREAM_FT_NOLIVE);
                ^
  1523.         return;
  1524.     }

src/http/ngx_http_upstream.c:4083:1: Parameter `r->uri_changes`
    4081. 
    4082. 
    4083. static void
          ^
    4084. ngx_http_upstream_next(ngx_http_request_t *r, ngx_http_upstream_t *u,
    4085.     ngx_uint_t ft_type)

src/http/ngx_http_upstream.c:4155:9: Call
    4153. 
    4154.     if (r->connection->error) {
    4155.         ngx_http_upstream_finalize_request(r, u,
                  ^
    4156.                                            NGX_HTTP_CLIENT_CLOSED_REQUEST);
    4157.         return;

src/http/ngx_http_upstream.c:4247:1: Parameter `r->uri_changes`
      4245. 
      4246. 
      4247. static void
            ^
      4248. ngx_http_upstream_finalize_request(ngx_http_request_t *r,
      4249.     ngx_http_upstream_t *u, ngx_int_t rc)

src/http/ngx_http_upstream.c:4258:9: Call
      4256.     if (u->cleanup == NULL) {
      4257.         /* the request was already finalized */
      4258.         ngx_http_finalize_request(r, NGX_DONE);
                    ^
      4259.         return;
      4260.     }

src/http/ngx_http_request.c:2307:1: Parameter `r->uri_changes`
        2305. 
        2306. 
        2307. void
              ^
        2308. ngx_http_finalize_request(ngx_http_request_t *r, ngx_int_t rc)
        2309. {

src/http/ngx_http_request.c:2345:13: Call
        2343.         || c->error)
        2344.     {
        2345.         if (ngx_http_post_action(r) == NGX_OK) {
                          ^
        2346.             return;
        2347.         }

src/http/ngx_http_request.c:3391:1: Parameter `r->uri_changes`
          3389. 
          3390. 
          3391. static ngx_int_t
                ^
          3392. ngx_http_post_action(ngx_http_request_t *r)
          3393. {

src/http/ngx_http_request.c:3418:9: Call
          3416. 
          3417.     if (clcf->post_action.data[0] == '/') {
          3418.         ngx_http_internal_redirect(r, &clcf->post_action, NULL);
                        ^
          3419. 
          3420.     } else {

src/http/ngx_http_core_module.c:2378:1: <LHS trace>
2376. 
2377. 
2378. ngx_int_t
      ^
2379. ngx_http_internal_redirect(ngx_http_request_t *r,
2380.     ngx_str_t *uri, ngx_str_t *args)

src/http/ngx_http_core_module.c:2378:1: Parameter `r->uri_changes`
            2376. 
            2377. 
            2378. ngx_int_t
                  ^
            2379. ngx_http_internal_redirect(ngx_http_request_t *r,
            2380.     ngx_str_t *uri, ngx_str_t *args)

src/http/ngx_http_core_module.c:2384:5: Binary operation: ([0, r->uri_changes] - 1):unsigned32 by call to `ngx_http_upstream_connect` 
            2382.     ngx_http_core_srv_conf_t  *cscf;
            2383. 
            2384.     r->uri_changes--;
                      ^
            2385. 
            2386.     if (r->uri_changes == 0) {

ngx_int_t
ngx_http_internal_redirect(ngx_http_request_t *r,
    ngx_str_t *uri, ngx_str_t *args)
{
    ngx_http_core_srv_conf_t  *cscf;
    r->uri_changes--;
    if (r->uri_changes == 0) {
        ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
                      "rewrite or internal redirection cycle "
                      "while internally redirecting to \"%V\"", uri);
        r->main->count++;
        ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
        return NGX_DONE;
    }
    r->uri = *uri;
    if (args) {
        r->args = *args;
    } else {
        ngx_str_null(&r->args);
    }
    ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
                   "internal redirect: \"%V?%V\"", uri, &r->args);
    ngx_http_set_exten(r);
    ngx_memzero(r->ctx, sizeof(void *) * ngx_http_max_module);
    cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module);
    r->loc_conf = cscf->ctx->loc_conf;
    ngx_http_update_location_config(r);
#if (NGX_HTTP_CACHE)
    r->cache = NULL;
#endif
    r->internal = 1;
    r->valid_unparsed_uri = 0;
    r->add_uri_to_alias = 0;
    r->main->count++;
    ngx_http_handler(r);
    return NGX_DONE;
}
['static void\nngx_http_upstream_init_request(ngx_http_request_t *r)\n{\n    ngx_str_t                      *host;\n    ngx_uint_t                      i;\n    ngx_resolver_ctx_t             *ctx, temp;\n    ngx_http_cleanup_t             *cln;\n    ngx_http_upstream_t            *u;\n    ngx_http_core_loc_conf_t       *clcf;\n    ngx_http_upstream_srv_conf_t   *uscf, **uscfp;\n    ngx_http_upstream_main_conf_t  *umcf;\n    if (r->aio) {\n        return;\n    }\n    u = r->upstream;\n#if (NGX_HTTP_CACHE)\n    if (u->conf->cache) {\n        ngx_int_t  rc;\n        rc = ngx_http_upstream_cache(r, u);\n        if (rc == NGX_BUSY) {\n            r->write_event_handler = ngx_http_upstream_init_request;\n            return;\n        }\n        r->write_event_handler = ngx_http_request_empty_handler;\n        if (rc == NGX_ERROR) {\n            ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);\n            return;\n        }\n        if (rc == NGX_OK) {\n            rc = ngx_http_upstream_cache_send(r, u);\n            if (rc == NGX_DONE) {\n                return;\n            }\n            if (rc == NGX_HTTP_UPSTREAM_INVALID_HEADER) {\n                rc = NGX_DECLINED;\n                r->cached = 0;\n                u->buffer.start = NULL;\n                u->cache_status = NGX_HTTP_CACHE_MISS;\n                u->request_sent = 1;\n            }\n            if (ngx_http_upstream_cache_background_update(r, u) != NGX_OK) {\n                rc = NGX_ERROR;\n            }\n        }\n        if (rc != NGX_DECLINED) {\n            ngx_http_finalize_request(r, rc);\n            return;\n        }\n    }\n#endif\n    u->store = u->conf->store;\n    if (!u->store && !r->post_action && !u->conf->ignore_client_abort) {\n        r->read_event_handler = ngx_http_upstream_rd_check_broken_connection;\n        r->write_event_handler = ngx_http_upstream_wr_check_broken_connection;\n    }\n    if (r->request_body) {\n        u->request_bufs = r->request_body->bufs;\n    }\n    if (u->create_request(r) != NGX_OK) {\n        ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);\n        return;\n    }\n    if (ngx_http_upstream_set_local(r, u, u->conf->local) != NGX_OK) {\n        ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);\n        return;\n    }\n    clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);\n    u->output.alignment = clcf->directio_alignment;\n    u->output.pool = r->pool;\n    u->output.bufs.num = 1;\n    u->output.bufs.size = clcf->client_body_buffer_size;\n    if (u->output.output_filter == NULL) {\n        u->output.output_filter = ngx_chain_writer;\n        u->output.filter_ctx = &u->writer;\n    }\n    u->writer.pool = r->pool;\n    if (r->upstream_states == NULL) {\n        r->upstream_states = ngx_array_create(r->pool, 1,\n                                            sizeof(ngx_http_upstream_state_t));\n        if (r->upstream_states == NULL) {\n            ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);\n            return;\n        }\n    } else {\n        u->state = ngx_array_push(r->upstream_states);\n        if (u->state == NULL) {\n            ngx_http_upstream_finalize_request(r, u,\n                                               NGX_HTTP_INTERNAL_SERVER_ERROR);\n            return;\n        }\n        ngx_memzero(u->state, sizeof(ngx_http_upstream_state_t));\n    }\n    cln = ngx_http_cleanup_add(r, 0);\n    if (cln == NULL) {\n        ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);\n        return;\n    }\n    cln->handler = ngx_http_upstream_cleanup;\n    cln->data = r;\n    u->cleanup = &cln->handler;\n    if (u->resolved == NULL) {\n        uscf = u->conf->upstream;\n    } else {\n#if (NGX_HTTP_SSL)\n        u->ssl_name = u->resolved->host;\n#endif\n        host = &u->resolved->host;\n        umcf = ngx_http_get_module_main_conf(r, ngx_http_upstream_module);\n        uscfp = umcf->upstreams.elts;\n        for (i = 0; i < umcf->upstreams.nelts; i++) {\n            uscf = uscfp[i];\n            if (uscf->host.len == host->len\n                && ((uscf->port == 0 && u->resolved->no_port)\n                     || uscf->port == u->resolved->port)\n                && ngx_strncasecmp(uscf->host.data, host->data, host->len) == 0)\n            {\n                goto found;\n            }\n        }\n        if (u->resolved->sockaddr) {\n            if (u->resolved->port == 0\n                && u->resolved->sockaddr->sa_family != AF_UNIX)\n            {\n                ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,\n                              "no port in upstream \\"%V\\"", host);\n                ngx_http_upstream_finalize_request(r, u,\n                                               NGX_HTTP_INTERNAL_SERVER_ERROR);\n                return;\n            }\n            if (ngx_http_upstream_create_round_robin_peer(r, u->resolved)\n                != NGX_OK)\n            {\n                ngx_http_upstream_finalize_request(r, u,\n                                               NGX_HTTP_INTERNAL_SERVER_ERROR);\n                return;\n            }\n            ngx_http_upstream_connect(r, u);\n            return;\n        }\n        if (u->resolved->port == 0) {\n            ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,\n                          "no port in upstream \\"%V\\"", host);\n            ngx_http_upstream_finalize_request(r, u,\n                                               NGX_HTTP_INTERNAL_SERVER_ERROR);\n            return;\n        }\n        temp.name = *host;\n        ctx = ngx_resolve_start(clcf->resolver, &temp);\n        if (ctx == NULL) {\n            ngx_http_upstream_finalize_request(r, u,\n                                               NGX_HTTP_INTERNAL_SERVER_ERROR);\n            return;\n        }\n        if (ctx == NGX_NO_RESOLVER) {\n            ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,\n                          "no resolver defined to resolve %V", host);\n            ngx_http_upstream_finalize_request(r, u, NGX_HTTP_BAD_GATEWAY);\n            return;\n        }\n        ctx->name = *host;\n        ctx->handler = ngx_http_upstream_resolve_handler;\n        ctx->data = r;\n        ctx->timeout = clcf->resolver_timeout;\n        u->resolved->ctx = ctx;\n        if (ngx_resolve_name(ctx) != NGX_OK) {\n            u->resolved->ctx = NULL;\n            ngx_http_upstream_finalize_request(r, u,\n                                               NGX_HTTP_INTERNAL_SERVER_ERROR);\n            return;\n        }\n        return;\n    }\nfound:\n    if (uscf == NULL) {\n        ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0,\n                      "no upstream configuration");\n        ngx_http_upstream_finalize_request(r, u,\n                                           NGX_HTTP_INTERNAL_SERVER_ERROR);\n        return;\n    }\n    u->upstream = uscf;\n#if (NGX_HTTP_SSL)\n    u->ssl_name = uscf->host;\n#endif\n    if (uscf->peer.init(r, uscf) != NGX_OK) {\n        ngx_http_upstream_finalize_request(r, u,\n                                           NGX_HTTP_INTERNAL_SERVER_ERROR);\n        return;\n    }\n    u->peer.start_time = ngx_current_msec;\n    if (u->conf->next_upstream_tries\n        && u->peer.tries > u->conf->next_upstream_tries)\n    {\n        u->peer.tries = u->conf->next_upstream_tries;\n    }\n    ngx_http_upstream_connect(r, u);\n}', 'static void\nngx_http_upstream_connect(ngx_http_request_t *r, ngx_http_upstream_t *u)\n{\n    ngx_int_t          rc;\n    ngx_connection_t  *c;\n    r->connection->log->action = "connecting to upstream";\n    if (u->state && u->state->response_time) {\n        u->state->response_time = ngx_current_msec - u->state->response_time;\n    }\n    u->state = ngx_array_push(r->upstream_states);\n    if (u->state == NULL) {\n        ngx_http_upstream_finalize_request(r, u,\n                                           NGX_HTTP_INTERNAL_SERVER_ERROR);\n        return;\n    }\n    ngx_memzero(u->state, sizeof(ngx_http_upstream_state_t));\n    u->state->response_time = ngx_current_msec;\n    u->state->connect_time = (ngx_msec_t) -1;\n    u->state->header_time = (ngx_msec_t) -1;\n    rc = ngx_event_connect_peer(&u->peer);\n    ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,\n                   "http upstream connect: %i", rc);\n    if (rc == NGX_ERROR) {\n        ngx_http_upstream_finalize_request(r, u,\n                                           NGX_HTTP_INTERNAL_SERVER_ERROR);\n        return;\n    }\n    u->state->peer = u->peer.name;\n    if (rc == NGX_BUSY) {\n        ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "no live upstreams");\n        ngx_http_upstream_next(r, u, NGX_HTTP_UPSTREAM_FT_NOLIVE);\n        return;\n    }\n    if (rc == NGX_DECLINED) {\n        ngx_http_upstream_next(r, u, NGX_HTTP_UPSTREAM_FT_ERROR);\n        return;\n    }\n    c = u->peer.connection;\n    c->data = r;\n    c->write->handler = ngx_http_upstream_handler;\n    c->read->handler = ngx_http_upstream_handler;\n    u->write_event_handler = ngx_http_upstream_send_request_handler;\n    u->read_event_handler = ngx_http_upstream_process_header;\n    c->sendfile &= r->connection->sendfile;\n    u->output.sendfile = c->sendfile;\n    if (c->pool == NULL) {\n        c->pool = ngx_create_pool(128, r->connection->log);\n        if (c->pool == NULL) {\n            ngx_http_upstream_finalize_request(r, u,\n                                               NGX_HTTP_INTERNAL_SERVER_ERROR);\n            return;\n        }\n    }\n    c->log = r->connection->log;\n    c->pool->log = c->log;\n    c->read->log = c->log;\n    c->write->log = c->log;\n    u->writer.out = NULL;\n    u->writer.last = &u->writer.out;\n    u->writer.connection = c;\n    u->writer.limit = 0;\n    if (u->request_sent) {\n        if (ngx_http_upstream_reinit(r, u) != NGX_OK) {\n            ngx_http_upstream_finalize_request(r, u,\n                                               NGX_HTTP_INTERNAL_SERVER_ERROR);\n            return;\n        }\n    }\n    if (r->request_body\n        && r->request_body->buf\n        && r->request_body->temp_file\n        && r == r->main)\n    {\n        u->output.free = ngx_alloc_chain_link(r->pool);\n        if (u->output.free == NULL) {\n            ngx_http_upstream_finalize_request(r, u,\n                                               NGX_HTTP_INTERNAL_SERVER_ERROR);\n            return;\n        }\n        u->output.free->buf = r->request_body->buf;\n        u->output.free->next = NULL;\n        u->output.allocated = 1;\n        r->request_body->buf->pos = r->request_body->buf->start;\n        r->request_body->buf->last = r->request_body->buf->start;\n        r->request_body->buf->tag = u->output.tag;\n    }\n    u->request_sent = 0;\n    u->request_body_sent = 0;\n    if (rc == NGX_AGAIN) {\n        ngx_add_timer(c->write, u->conf->connect_timeout);\n        return;\n    }\n#if (NGX_HTTP_SSL)\n    if (u->ssl && c->ssl == NULL) {\n        ngx_http_upstream_ssl_init_connection(r, u, c);\n        return;\n    }\n#endif\n    ngx_http_upstream_send_request(r, u, 1);\n}', 'static void\nngx_http_upstream_next(ngx_http_request_t *r, ngx_http_upstream_t *u,\n    ngx_uint_t ft_type)\n{\n    ngx_msec_t  timeout;\n    ngx_uint_t  status, state;\n    ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,\n                   "http next upstream, %xi", ft_type);\n    if (u->peer.sockaddr) {\n        if (ft_type == NGX_HTTP_UPSTREAM_FT_HTTP_403\n            || ft_type == NGX_HTTP_UPSTREAM_FT_HTTP_404)\n        {\n            state = NGX_PEER_NEXT;\n        } else {\n            state = NGX_PEER_FAILED;\n        }\n        u->peer.free(&u->peer, u->peer.data, state);\n        u->peer.sockaddr = NULL;\n    }\n    if (ft_type == NGX_HTTP_UPSTREAM_FT_TIMEOUT) {\n        ngx_log_error(NGX_LOG_ERR, r->connection->log, NGX_ETIMEDOUT,\n                      "upstream timed out");\n    }\n    if (u->peer.cached && ft_type == NGX_HTTP_UPSTREAM_FT_ERROR) {\n        u->peer.tries++;\n    }\n    switch (ft_type) {\n    case NGX_HTTP_UPSTREAM_FT_TIMEOUT:\n    case NGX_HTTP_UPSTREAM_FT_HTTP_504:\n        status = NGX_HTTP_GATEWAY_TIME_OUT;\n        break;\n    case NGX_HTTP_UPSTREAM_FT_HTTP_500:\n        status = NGX_HTTP_INTERNAL_SERVER_ERROR;\n        break;\n    case NGX_HTTP_UPSTREAM_FT_HTTP_503:\n        status = NGX_HTTP_SERVICE_UNAVAILABLE;\n        break;\n    case NGX_HTTP_UPSTREAM_FT_HTTP_403:\n        status = NGX_HTTP_FORBIDDEN;\n        break;\n    case NGX_HTTP_UPSTREAM_FT_HTTP_404:\n        status = NGX_HTTP_NOT_FOUND;\n        break;\n    case NGX_HTTP_UPSTREAM_FT_HTTP_429:\n        status = NGX_HTTP_TOO_MANY_REQUESTS;\n        break;\n    default:\n        status = NGX_HTTP_BAD_GATEWAY;\n    }\n    if (r->connection->error) {\n        ngx_http_upstream_finalize_request(r, u,\n                                           NGX_HTTP_CLIENT_CLOSED_REQUEST);\n        return;\n    }\n    u->state->status = status;\n    timeout = u->conf->next_upstream_timeout;\n    if (u->request_sent\n        && (r->method & (NGX_HTTP_POST|NGX_HTTP_LOCK|NGX_HTTP_PATCH)))\n    {\n        ft_type |= NGX_HTTP_UPSTREAM_FT_NON_IDEMPOTENT;\n    }\n    if (u->peer.tries == 0\n        || ((u->conf->next_upstream & ft_type) != ft_type)\n        || (u->request_sent && r->request_body_no_buffering)\n        || (timeout && ngx_current_msec - u->peer.start_time >= timeout))\n    {\n#if (NGX_HTTP_CACHE)\n        if (u->cache_status == NGX_HTTP_CACHE_EXPIRED\n            && ((u->conf->cache_use_stale & ft_type) || r->cache->stale_error))\n        {\n            ngx_int_t  rc;\n            rc = u->reinit_request(r);\n            if (rc != NGX_OK) {\n                ngx_http_upstream_finalize_request(r, u, rc);\n                return;\n            }\n            u->cache_status = NGX_HTTP_CACHE_STALE;\n            rc = ngx_http_upstream_cache_send(r, u);\n            if (rc == NGX_DONE) {\n                return;\n            }\n            if (rc == NGX_HTTP_UPSTREAM_INVALID_HEADER) {\n                rc = NGX_HTTP_INTERNAL_SERVER_ERROR;\n            }\n            ngx_http_upstream_finalize_request(r, u, rc);\n            return;\n        }\n#endif\n        ngx_http_upstream_finalize_request(r, u, status);\n        return;\n    }\n    if (u->peer.connection) {\n        ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,\n                       "close http upstream connection: %d",\n                       u->peer.connection->fd);\n#if (NGX_HTTP_SSL)\n        if (u->peer.connection->ssl) {\n            u->peer.connection->ssl->no_wait_shutdown = 1;\n            u->peer.connection->ssl->no_send_shutdown = 1;\n            (void) ngx_ssl_shutdown(u->peer.connection);\n        }\n#endif\n        if (u->peer.connection->pool) {\n            ngx_destroy_pool(u->peer.connection->pool);\n        }\n        ngx_close_connection(u->peer.connection);\n        u->peer.connection = NULL;\n    }\n    ngx_http_upstream_connect(r, u);\n}', 'static void\nngx_http_upstream_finalize_request(ngx_http_request_t *r,\n    ngx_http_upstream_t *u, ngx_int_t rc)\n{\n    ngx_uint_t  flush;\n    ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,\n                   "finalize http upstream request: %i", rc);\n    if (u->cleanup == NULL) {\n        ngx_http_finalize_request(r, NGX_DONE);\n        return;\n    }\n    *u->cleanup = NULL;\n    u->cleanup = NULL;\n    if (u->resolved && u->resolved->ctx) {\n        ngx_resolve_name_done(u->resolved->ctx);\n        u->resolved->ctx = NULL;\n    }\n    if (u->state && u->state->response_time) {\n        u->state->response_time = ngx_current_msec - u->state->response_time;\n        if (u->pipe && u->pipe->read_length) {\n            u->state->bytes_received += u->pipe->read_length\n                                        - u->pipe->preread_size;\n            u->state->response_length = u->pipe->read_length;\n        }\n    }\n    u->finalize_request(r, rc);\n    if (u->peer.free && u->peer.sockaddr) {\n        u->peer.free(&u->peer, u->peer.data, 0);\n        u->peer.sockaddr = NULL;\n    }\n    if (u->peer.connection) {\n#if (NGX_HTTP_SSL)\n        if (u->peer.connection->ssl) {\n            u->peer.connection->ssl->no_wait_shutdown = 1;\n            (void) ngx_ssl_shutdown(u->peer.connection);\n        }\n#endif\n        ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,\n                       "close http upstream connection: %d",\n                       u->peer.connection->fd);\n        if (u->peer.connection->pool) {\n            ngx_destroy_pool(u->peer.connection->pool);\n        }\n        ngx_close_connection(u->peer.connection);\n    }\n    u->peer.connection = NULL;\n    if (u->pipe && u->pipe->temp_file) {\n        ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,\n                       "http upstream temp fd: %d",\n                       u->pipe->temp_file->file.fd);\n    }\n    if (u->store && u->pipe && u->pipe->temp_file\n        && u->pipe->temp_file->file.fd != NGX_INVALID_FILE)\n    {\n        if (ngx_delete_file(u->pipe->temp_file->file.name.data)\n            == NGX_FILE_ERROR)\n        {\n            ngx_log_error(NGX_LOG_CRIT, r->connection->log, ngx_errno,\n                          ngx_delete_file_n " \\"%s\\" failed",\n                          u->pipe->temp_file->file.name.data);\n        }\n    }\n#if (NGX_HTTP_CACHE)\n    if (r->cache) {\n        if (u->cacheable) {\n            if (rc == NGX_HTTP_BAD_GATEWAY || rc == NGX_HTTP_GATEWAY_TIME_OUT) {\n                time_t  valid;\n                valid = ngx_http_file_cache_valid(u->conf->cache_valid, rc);\n                if (valid) {\n                    r->cache->valid_sec = ngx_time() + valid;\n                    r->cache->error = rc;\n                }\n            }\n        }\n        ngx_http_file_cache_free(r->cache, u->pipe->temp_file);\n    }\n#endif\n    if (r->subrequest_in_memory\n        && u->headers_in.status_n >= NGX_HTTP_SPECIAL_RESPONSE)\n    {\n        u->buffer.last = u->buffer.pos;\n    }\n    r->read_event_handler = ngx_http_block_reading;\n    if (rc == NGX_DECLINED) {\n        return;\n    }\n    r->connection->log->action = "sending to client";\n    if (!u->header_sent\n        || rc == NGX_HTTP_REQUEST_TIME_OUT\n        || rc == NGX_HTTP_CLIENT_CLOSED_REQUEST)\n    {\n        ngx_http_finalize_request(r, rc);\n        return;\n    }\n    flush = 0;\n    if (rc >= NGX_HTTP_SPECIAL_RESPONSE) {\n        rc = NGX_ERROR;\n        flush = 1;\n    }\n    if (r->header_only\n        || (u->pipe && u->pipe->downstream_error))\n    {\n        ngx_http_finalize_request(r, rc);\n        return;\n    }\n    if (rc == 0) {\n        rc = ngx_http_send_special(r, NGX_HTTP_LAST);\n    } else if (flush) {\n        r->keepalive = 0;\n        rc = ngx_http_send_special(r, NGX_HTTP_FLUSH);\n    }\n    ngx_http_finalize_request(r, rc);\n}', 'void\nngx_http_finalize_request(ngx_http_request_t *r, ngx_int_t rc)\n{\n    ngx_connection_t          *c;\n    ngx_http_request_t        *pr;\n    ngx_http_core_loc_conf_t  *clcf;\n    c = r->connection;\n    ngx_log_debug5(NGX_LOG_DEBUG_HTTP, c->log, 0,\n                   "http finalize request: %i, \\"%V?%V\\" a:%d, c:%d",\n                   rc, &r->uri, &r->args, r == c->data, r->main->count);\n    if (rc == NGX_DONE) {\n        ngx_http_finalize_connection(r);\n        return;\n    }\n    if (rc == NGX_OK && r->filter_finalize) {\n        c->error = 1;\n    }\n    if (rc == NGX_DECLINED) {\n        r->content_handler = NULL;\n        r->write_event_handler = ngx_http_core_run_phases;\n        ngx_http_core_run_phases(r);\n        return;\n    }\n    if (r != r->main && r->post_subrequest) {\n        rc = r->post_subrequest->handler(r, r->post_subrequest->data, rc);\n    }\n    if (rc == NGX_ERROR\n        || rc == NGX_HTTP_REQUEST_TIME_OUT\n        || rc == NGX_HTTP_CLIENT_CLOSED_REQUEST\n        || c->error)\n    {\n        if (ngx_http_post_action(r) == NGX_OK) {\n            return;\n        }\n        ngx_http_terminate_request(r, rc);\n        return;\n    }\n    if (rc >= NGX_HTTP_SPECIAL_RESPONSE\n        || rc == NGX_HTTP_CREATED\n        || rc == NGX_HTTP_NO_CONTENT)\n    {\n        if (rc == NGX_HTTP_CLOSE) {\n            ngx_http_terminate_request(r, rc);\n            return;\n        }\n        if (r == r->main) {\n            if (c->read->timer_set) {\n                ngx_del_timer(c->read);\n            }\n            if (c->write->timer_set) {\n                ngx_del_timer(c->write);\n            }\n        }\n        c->read->handler = ngx_http_request_handler;\n        c->write->handler = ngx_http_request_handler;\n        ngx_http_finalize_request(r, ngx_http_special_response_handler(r, rc));\n        return;\n    }\n    if (r != r->main) {\n        clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);\n        if (r->background) {\n            if (!r->logged) {\n                if (clcf->log_subrequest) {\n                    ngx_http_log_request(r);\n                }\n                r->logged = 1;\n            } else {\n                ngx_log_error(NGX_LOG_ALERT, c->log, 0,\n                              "subrequest: \\"%V?%V\\" logged again",\n                              &r->uri, &r->args);\n            }\n            r->done = 1;\n            ngx_http_finalize_connection(r);\n            return;\n        }\n        if (r->buffered || r->postponed) {\n            if (ngx_http_set_write_handler(r) != NGX_OK) {\n                ngx_http_terminate_request(r, 0);\n            }\n            return;\n        }\n        pr = r->parent;\n        if (r == c->data) {\n            r->main->count--;\n            if (!r->logged) {\n                if (clcf->log_subrequest) {\n                    ngx_http_log_request(r);\n                }\n                r->logged = 1;\n            } else {\n                ngx_log_error(NGX_LOG_ALERT, c->log, 0,\n                              "subrequest: \\"%V?%V\\" logged again",\n                              &r->uri, &r->args);\n            }\n            r->done = 1;\n            if (pr->postponed && pr->postponed->request == r) {\n                pr->postponed = pr->postponed->next;\n            }\n            c->data = pr;\n        } else {\n            ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0,\n                           "http finalize non-active request: \\"%V?%V\\"",\n                           &r->uri, &r->args);\n            r->write_event_handler = ngx_http_request_finalizer;\n            if (r->waited) {\n                r->done = 1;\n            }\n        }\n        if (ngx_http_post_request(pr, NULL) != NGX_OK) {\n            r->main->count++;\n            ngx_http_terminate_request(r, 0);\n            return;\n        }\n        ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0,\n                       "http wake parent request: \\"%V?%V\\"",\n                       &pr->uri, &pr->args);\n        return;\n    }\n    if (r->buffered || c->buffered || r->postponed) {\n        if (ngx_http_set_write_handler(r) != NGX_OK) {\n            ngx_http_terminate_request(r, 0);\n        }\n        return;\n    }\n    if (r != c->data) {\n        ngx_log_error(NGX_LOG_ALERT, c->log, 0,\n                      "http finalize non-active request: \\"%V?%V\\"",\n                      &r->uri, &r->args);\n        return;\n    }\n    r->done = 1;\n    r->read_event_handler = ngx_http_block_reading;\n    r->write_event_handler = ngx_http_request_empty_handler;\n    if (!r->post_action) {\n        r->request_complete = 1;\n    }\n    if (ngx_http_post_action(r) == NGX_OK) {\n        return;\n    }\n    if (c->read->timer_set) {\n        ngx_del_timer(c->read);\n    }\n    if (c->write->timer_set) {\n        c->write->delayed = 0;\n        ngx_del_timer(c->write);\n    }\n    if (c->read->eof) {\n        ngx_http_close_request(r, 0);\n        return;\n    }\n    ngx_http_finalize_connection(r);\n}', 'static ngx_int_t\nngx_http_post_action(ngx_http_request_t *r)\n{\n    ngx_http_core_loc_conf_t  *clcf;\n    clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);\n    if (clcf->post_action.data == NULL) {\n        return NGX_DECLINED;\n    }\n    if (r->post_action && r->uri_changes == 0) {\n        return NGX_DECLINED;\n    }\n    ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,\n                   "post action: \\"%V\\"", &clcf->post_action);\n    r->main->count--;\n    r->http_version = NGX_HTTP_VERSION_9;\n    r->header_only = 1;\n    r->post_action = 1;\n    r->read_event_handler = ngx_http_block_reading;\n    if (clcf->post_action.data[0] == \'/\') {\n        ngx_http_internal_redirect(r, &clcf->post_action, NULL);\n    } else {\n        ngx_http_named_location(r, &clcf->post_action);\n    }\n    return NGX_OK;\n}', 'ngx_int_t\nngx_http_internal_redirect(ngx_http_request_t *r,\n    ngx_str_t *uri, ngx_str_t *args)\n{\n    ngx_http_core_srv_conf_t  *cscf;\n    r->uri_changes--;\n    if (r->uri_changes == 0) {\n        ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,\n                      "rewrite or internal redirection cycle "\n                      "while internally redirecting to \\"%V\\"", uri);\n        r->main->count++;\n        ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);\n        return NGX_DONE;\n    }\n    r->uri = *uri;\n    if (args) {\n        r->args = *args;\n    } else {\n        ngx_str_null(&r->args);\n    }\n    ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,\n                   "internal redirect: \\"%V?%V\\"", uri, &r->args);\n    ngx_http_set_exten(r);\n    ngx_memzero(r->ctx, sizeof(void *) * ngx_http_max_module);\n    cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module);\n    r->loc_conf = cscf->ctx->loc_conf;\n    ngx_http_update_location_config(r);\n#if (NGX_HTTP_CACHE)\n    r->cache = NULL;\n#endif\n    r->internal = 1;\n    r->valid_unparsed_uri = 0;\n    r->add_uri_to_alias = 0;\n    r->main->count++;\n    ngx_http_handler(r);\n    return NGX_DONE;\n}']