src/http/ngx_http_upstream.c:2328: error: Integer Overflow L2
  ([0, `r->uri.len`] - 1):unsigned64 by call to `ngx_http_upstream_intercept_errors`.

src/http/ngx_http_upstream.c:2193:1: Parameter `r->uri.len`
2191. 
2192. 
2193. static void
      ^
2194. ngx_http_upstream_process_header(ngx_http_request_t *r, ngx_http_upstream_t *u)
2195. {

src/http/ngx_http_upstream.c:2324:13: Call
2322.     if (u->headers_in.status_n >= NGX_HTTP_SPECIAL_RESPONSE) {
2323. 
2324.         if (ngx_http_upstream_test_next(r, u) == NGX_OK) {
                  ^
2325.             return;
2326.         }

src/http/ngx_http_upstream.c:2379:1: Parameter `r->uri.len`
  2377. 
  2378. 
  2379. static ngx_int_t
        ^
  2380. ngx_http_upstream_test_next(ngx_http_request_t *r, ngx_http_upstream_t *u)
  2381. {

src/http/ngx_http_upstream.c:2328:13: Call
2326.         }
2327. 
2328.         if (ngx_http_upstream_intercept_errors(r, u) == NGX_OK) {
                  ^
2329.             return;
2330.         }

src/http/ngx_http_upstream.c:2500:1: Parameter `r->uri.len`
  2498. 
  2499. 
  2500. static ngx_int_t
        ^
  2501. ngx_http_upstream_intercept_errors(ngx_http_request_t *r,
  2502.     ngx_http_upstream_t *u)

src/http/ngx_http_upstream.c:2538:21: Call
  2536. 
  2537.                 if (h == NULL) {
  2538.                     ngx_http_upstream_finalize_request(r, u,
                            ^
  2539.                                                NGX_HTTP_INTERNAL_SERVER_ERROR);
  2540.                     return NGX_OK;

src/http/ngx_http_upstream.c:4247:1: Parameter `r->uri.len`
    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.len`
      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:2375:38: Call
      2373.         c->write->handler = ngx_http_request_handler;
      2374. 
      2375.         ngx_http_finalize_request(r, ngx_http_special_response_handler(r, rc));
                                                 ^
      2376.         return;
      2377.     }

src/http/ngx_http_special_response.c:415:1: Parameter `r->uri.len`
        413. 
        414. 
        415. ngx_int_t
             ^
        416. ngx_http_special_response_handler(ngx_http_request_t *r, ngx_int_t error)
        417. {

src/http/ngx_http_special_response.c:466:24: Call
        464.         for (i = 0; i < clcf->error_pages->nelts; i++) {
        465.             if (err_page[i].status == error) {
        466.                 return ngx_http_send_error_page(r, &err_page[i]);
                                    ^
        467.             }
        468.         }

src/http/ngx_http_special_response.c:583:1: Parameter `r->uri.len`
          581. 
          582. 
          583. static ngx_int_t
               ^
          584. ngx_http_send_error_page(ngx_http_request_t *r, ngx_http_err_page_t *err_page)
          585. {

src/http/ngx_http_special_response.c:619:16: Call
          617.         }
          618. 
          619.         return ngx_http_internal_redirect(r, &uri, &args);
                              ^
          620.     }
          621. 

src/http/ngx_http_core_module.c:2378:1: Parameter `r->uri.len`
            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:2408:5: Call
            2406.                    "internal redirect: \"%V?%V\"", uri, &r->args);
            2407. 
            2408.     ngx_http_set_exten(r);
                      ^
            2409. 
            2410.     /* clear the modules contexts */

src/http/ngx_http_core_module.c:1550:1: <LHS trace>
1548. 
1549. 
1550. void
      ^
1551. ngx_http_set_exten(ngx_http_request_t *r)
1552. {

src/http/ngx_http_core_module.c:1550:1: Parameter `r->uri.len`
              1548. 
              1549. 
              1550. void
                    ^
              1551. ngx_http_set_exten(ngx_http_request_t *r)
              1552. {

src/http/ngx_http_core_module.c:1557:10: Binary operation: ([0, r->uri.len] - 1):unsigned64 by call to `ngx_http_upstream_intercept_errors` 
              1555.     ngx_str_null(&r->exten);
              1556. 
              1557.     for (i = r->uri.len - 1; i > 1; i--) {
                             ^
              1558.         if (r->uri.data[i] == '.' && r->uri.data[i - 1] != '/') {
              1559. 

void
ngx_http_set_exten(ngx_http_request_t *r)
{
    ngx_int_t  i;
    ngx_str_null(&r->exten);
    for (i = r->uri.len - 1; i > 1; i--) {
        if (r->uri.data[i] == '.' && r->uri.data[i - 1] != '/') {
            r->exten.len = r->uri.len - i - 1;
            r->exten.data = &r->uri.data[i + 1];
            return;
        } else if (r->uri.data[i] == '/') {
            return;
        }
    }
    return;
}
['static void\nngx_http_upstream_process_header(ngx_http_request_t *r, ngx_http_upstream_t *u)\n{\n    ssize_t            n;\n    ngx_int_t          rc;\n    ngx_connection_t  *c;\n    c = u->peer.connection;\n    ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0,\n                   "http upstream process header");\n    c->log->action = "reading response header from upstream";\n    if (c->read->timedout) {\n        ngx_http_upstream_next(r, u, NGX_HTTP_UPSTREAM_FT_TIMEOUT);\n        return;\n    }\n    if (!u->request_sent && ngx_http_upstream_test_connect(c) != NGX_OK) {\n        ngx_http_upstream_next(r, u, NGX_HTTP_UPSTREAM_FT_ERROR);\n        return;\n    }\n    if (u->buffer.start == NULL) {\n        u->buffer.start = ngx_palloc(r->pool, u->conf->buffer_size);\n        if (u->buffer.start == NULL) {\n            ngx_http_upstream_finalize_request(r, u,\n                                               NGX_HTTP_INTERNAL_SERVER_ERROR);\n            return;\n        }\n        u->buffer.pos = u->buffer.start;\n        u->buffer.last = u->buffer.start;\n        u->buffer.end = u->buffer.start + u->conf->buffer_size;\n        u->buffer.temporary = 1;\n        u->buffer.tag = u->output.tag;\n        if (ngx_list_init(&u->headers_in.headers, r->pool, 8,\n                          sizeof(ngx_table_elt_t))\n            != NGX_OK)\n        {\n            ngx_http_upstream_finalize_request(r, u,\n                                               NGX_HTTP_INTERNAL_SERVER_ERROR);\n            return;\n        }\n#if (NGX_HTTP_CACHE)\n        if (r->cache) {\n            u->buffer.pos += r->cache->header_start;\n            u->buffer.last = u->buffer.pos;\n        }\n#endif\n    }\n    for ( ;; ) {\n        n = c->recv(c, u->buffer.last, u->buffer.end - u->buffer.last);\n        if (n == NGX_AGAIN) {\n#if 0\n            ngx_add_timer(rev, u->read_timeout);\n#endif\n            if (ngx_handle_read_event(c->read, 0) != NGX_OK) {\n                ngx_http_upstream_finalize_request(r, u,\n                                               NGX_HTTP_INTERNAL_SERVER_ERROR);\n                return;\n            }\n            return;\n        }\n        if (n == 0) {\n            ngx_log_error(NGX_LOG_ERR, c->log, 0,\n                          "upstream prematurely closed connection");\n        }\n        if (n == NGX_ERROR || n == 0) {\n            ngx_http_upstream_next(r, u, NGX_HTTP_UPSTREAM_FT_ERROR);\n            return;\n        }\n        u->state->bytes_received += n;\n        u->buffer.last += n;\n#if 0\n        u->valid_header_in = 0;\n        u->peer.cached = 0;\n#endif\n        rc = u->process_header(r);\n        if (rc == NGX_AGAIN) {\n            if (u->buffer.last == u->buffer.end) {\n                ngx_log_error(NGX_LOG_ERR, c->log, 0,\n                              "upstream sent too big header");\n                ngx_http_upstream_next(r, u,\n                                       NGX_HTTP_UPSTREAM_FT_INVALID_HEADER);\n                return;\n            }\n            continue;\n        }\n        break;\n    }\n    if (rc == NGX_HTTP_UPSTREAM_INVALID_HEADER) {\n        ngx_http_upstream_next(r, u, NGX_HTTP_UPSTREAM_FT_INVALID_HEADER);\n        return;\n    }\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->header_time = ngx_current_msec - u->state->response_time;\n    if (u->headers_in.status_n >= NGX_HTTP_SPECIAL_RESPONSE) {\n        if (ngx_http_upstream_test_next(r, u) == NGX_OK) {\n            return;\n        }\n        if (ngx_http_upstream_intercept_errors(r, u) == NGX_OK) {\n            return;\n        }\n    }\n    if (ngx_http_upstream_process_headers(r, u) != NGX_OK) {\n        return;\n    }\n    if (!r->subrequest_in_memory) {\n        ngx_http_upstream_send_response(r, u);\n        return;\n    }\n    if (u->input_filter == NULL) {\n        u->input_filter_init = ngx_http_upstream_non_buffered_filter_init;\n        u->input_filter = ngx_http_upstream_non_buffered_filter;\n        u->input_filter_ctx = r;\n    }\n    if (u->input_filter_init(u->input_filter_ctx) == NGX_ERROR) {\n        ngx_http_upstream_finalize_request(r, u, NGX_ERROR);\n        return;\n    }\n    n = u->buffer.last - u->buffer.pos;\n    if (n) {\n        u->buffer.last = u->buffer.pos;\n        u->state->response_length += n;\n        if (u->input_filter(u->input_filter_ctx, n) == NGX_ERROR) {\n            ngx_http_upstream_finalize_request(r, u, NGX_ERROR);\n            return;\n        }\n    }\n    if (u->length == 0) {\n        ngx_http_upstream_finalize_request(r, u, 0);\n        return;\n    }\n    u->read_event_handler = ngx_http_upstream_process_body_in_memory;\n    ngx_http_upstream_process_body_in_memory(r, u);\n}', 'static ngx_int_t\nngx_http_upstream_test_next(ngx_http_request_t *r, ngx_http_upstream_t *u)\n{\n    ngx_uint_t                 status;\n    ngx_http_upstream_next_t  *un;\n    status = u->headers_in.status_n;\n    for (un = ngx_http_upstream_next_errors; un->status; un++) {\n        if (status != un->status) {\n            continue;\n        }\n        if (u->peer.tries > 1 && (u->conf->next_upstream & un->mask)) {\n            ngx_http_upstream_next(r, u, un->mask);\n            return NGX_OK;\n        }\n#if (NGX_HTTP_CACHE)\n        if (u->cache_status == NGX_HTTP_CACHE_EXPIRED\n            && ((u->conf->cache_use_stale & un->mask) || 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 NGX_OK;\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 NGX_OK;\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 NGX_OK;\n        }\n#endif\n    }\n#if (NGX_HTTP_CACHE)\n    if (status == NGX_HTTP_NOT_MODIFIED\n        && u->cache_status == NGX_HTTP_CACHE_EXPIRED\n        && u->conf->cache_revalidate)\n    {\n        time_t     now, valid, updating, error;\n        ngx_int_t  rc;\n        ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,\n                       "http upstream not modified");\n        now = ngx_time();\n        valid = r->cache->valid_sec;\n        updating = r->cache->updating_sec;\n        error = r->cache->error_sec;\n        rc = u->reinit_request(r);\n        if (rc != NGX_OK) {\n            ngx_http_upstream_finalize_request(r, u, rc);\n            return NGX_OK;\n        }\n        u->cache_status = NGX_HTTP_CACHE_REVALIDATED;\n        rc = ngx_http_upstream_cache_send(r, u);\n        if (rc == NGX_DONE) {\n            return NGX_OK;\n        }\n        if (rc == NGX_HTTP_UPSTREAM_INVALID_HEADER) {\n            rc = NGX_HTTP_INTERNAL_SERVER_ERROR;\n        }\n        if (valid == 0) {\n            valid = r->cache->valid_sec;\n            updating = r->cache->updating_sec;\n            error = r->cache->error_sec;\n        }\n        if (valid == 0) {\n            valid = ngx_http_file_cache_valid(u->conf->cache_valid,\n                                              u->headers_in.status_n);\n            if (valid) {\n                valid = now + valid;\n            }\n        }\n        if (valid) {\n            r->cache->valid_sec = valid;\n            r->cache->updating_sec = updating;\n            r->cache->error_sec = error;\n            r->cache->date = now;\n            ngx_http_file_cache_update_header(r);\n        }\n        ngx_http_upstream_finalize_request(r, u, rc);\n        return NGX_OK;\n    }\n#endif\n    return NGX_DECLINED;\n}', 'static ngx_int_t\nngx_http_upstream_intercept_errors(ngx_http_request_t *r,\n    ngx_http_upstream_t *u)\n{\n    ngx_int_t                  status;\n    ngx_uint_t                 i;\n    ngx_table_elt_t           *h;\n    ngx_http_err_page_t       *err_page;\n    ngx_http_core_loc_conf_t  *clcf;\n    status = u->headers_in.status_n;\n    if (status == NGX_HTTP_NOT_FOUND && u->conf->intercept_404) {\n        ngx_http_upstream_finalize_request(r, u, NGX_HTTP_NOT_FOUND);\n        return NGX_OK;\n    }\n    if (!u->conf->intercept_errors) {\n        return NGX_DECLINED;\n    }\n    clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);\n    if (clcf->error_pages == NULL) {\n        return NGX_DECLINED;\n    }\n    err_page = clcf->error_pages->elts;\n    for (i = 0; i < clcf->error_pages->nelts; i++) {\n        if (err_page[i].status == status) {\n            if (status == NGX_HTTP_UNAUTHORIZED\n                && u->headers_in.www_authenticate)\n            {\n                h = ngx_list_push(&r->headers_out.headers);\n                if (h == NULL) {\n                    ngx_http_upstream_finalize_request(r, u,\n                                               NGX_HTTP_INTERNAL_SERVER_ERROR);\n                    return NGX_OK;\n                }\n                *h = *u->headers_in.www_authenticate;\n                r->headers_out.www_authenticate = h;\n            }\n#if (NGX_HTTP_CACHE)\n            if (r->cache) {\n                if (u->cacheable) {\n                    time_t  valid;\n                    valid = r->cache->valid_sec;\n                    if (valid == 0) {\n                        valid = ngx_http_file_cache_valid(u->conf->cache_valid,\n                                                          status);\n                        if (valid) {\n                            r->cache->valid_sec = ngx_time() + valid;\n                        }\n                    }\n                    if (valid) {\n                        r->cache->error = status;\n                    }\n                }\n                ngx_http_file_cache_free(r->cache, u->pipe->temp_file);\n            }\n#endif\n            ngx_http_upstream_finalize_request(r, u, status);\n            return NGX_OK;\n        }\n    }\n    return NGX_DECLINED;\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}', 'ngx_int_t\nngx_http_special_response_handler(ngx_http_request_t *r, ngx_int_t error)\n{\n    ngx_uint_t                 i, err;\n    ngx_http_err_page_t       *err_page;\n    ngx_http_core_loc_conf_t  *clcf;\n    ngx_log_debug3(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,\n                   "http special response: %i, \\"%V?%V\\"",\n                   error, &r->uri, &r->args);\n    r->err_status = error;\n    if (r->keepalive) {\n        switch (error) {\n            case NGX_HTTP_BAD_REQUEST:\n            case NGX_HTTP_REQUEST_ENTITY_TOO_LARGE:\n            case NGX_HTTP_REQUEST_URI_TOO_LARGE:\n            case NGX_HTTP_TO_HTTPS:\n            case NGX_HTTPS_CERT_ERROR:\n            case NGX_HTTPS_NO_CERT:\n            case NGX_HTTP_INTERNAL_SERVER_ERROR:\n            case NGX_HTTP_NOT_IMPLEMENTED:\n                r->keepalive = 0;\n        }\n    }\n    if (r->lingering_close) {\n        switch (error) {\n            case NGX_HTTP_BAD_REQUEST:\n            case NGX_HTTP_TO_HTTPS:\n            case NGX_HTTPS_CERT_ERROR:\n            case NGX_HTTPS_NO_CERT:\n                r->lingering_close = 0;\n        }\n    }\n    r->headers_out.content_type.len = 0;\n    clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);\n    if (!r->error_page && clcf->error_pages && r->uri_changes != 0) {\n        if (clcf->recursive_error_pages == 0) {\n            r->error_page = 1;\n        }\n        err_page = clcf->error_pages->elts;\n        for (i = 0; i < clcf->error_pages->nelts; i++) {\n            if (err_page[i].status == error) {\n                return ngx_http_send_error_page(r, &err_page[i]);\n            }\n        }\n    }\n    r->expect_tested = 1;\n    if (ngx_http_discard_request_body(r) != NGX_OK) {\n        r->keepalive = 0;\n    }\n    if (clcf->msie_refresh\n        && r->headers_in.msie\n        && (error == NGX_HTTP_MOVED_PERMANENTLY\n            || error == NGX_HTTP_MOVED_TEMPORARILY))\n    {\n        return ngx_http_send_refresh(r);\n    }\n    if (error == NGX_HTTP_CREATED) {\n        err = 0;\n    } else if (error == NGX_HTTP_NO_CONTENT) {\n        err = 0;\n    } else if (error >= NGX_HTTP_MOVED_PERMANENTLY\n               && error < NGX_HTTP_LAST_3XX)\n    {\n        err = error - NGX_HTTP_MOVED_PERMANENTLY + NGX_HTTP_OFF_3XX;\n    } else if (error >= NGX_HTTP_BAD_REQUEST\n               && error < NGX_HTTP_LAST_4XX)\n    {\n        err = error - NGX_HTTP_BAD_REQUEST + NGX_HTTP_OFF_4XX;\n    } else if (error >= NGX_HTTP_NGINX_CODES\n               && error < NGX_HTTP_LAST_5XX)\n    {\n        err = error - NGX_HTTP_NGINX_CODES + NGX_HTTP_OFF_5XX;\n        switch (error) {\n            case NGX_HTTP_TO_HTTPS:\n            case NGX_HTTPS_CERT_ERROR:\n            case NGX_HTTPS_NO_CERT:\n            case NGX_HTTP_REQUEST_HEADER_TOO_LARGE:\n                r->err_status = NGX_HTTP_BAD_REQUEST;\n        }\n    } else {\n        err = 0;\n    }\n    return ngx_http_send_special_response(r, clcf, err);\n}', 'static ngx_int_t\nngx_http_send_error_page(ngx_http_request_t *r, ngx_http_err_page_t *err_page)\n{\n    ngx_int_t                  overwrite;\n    ngx_str_t                  uri, args;\n    ngx_table_elt_t           *location;\n    ngx_http_core_loc_conf_t  *clcf;\n    overwrite = err_page->overwrite;\n    if (overwrite && overwrite != NGX_HTTP_OK) {\n        r->expect_tested = 1;\n    }\n    if (overwrite >= 0) {\n        r->err_status = overwrite;\n    }\n    if (ngx_http_complex_value(r, &err_page->value, &uri) != NGX_OK) {\n        return NGX_ERROR;\n    }\n    if (uri.len && uri.data[0] == \'/\') {\n        if (err_page->value.lengths) {\n            ngx_http_split_args(r, &uri, &args);\n        } else {\n            args = err_page->args;\n        }\n        if (r->method != NGX_HTTP_HEAD) {\n            r->method = NGX_HTTP_GET;\n            r->method_name = ngx_http_core_get_method;\n        }\n        return ngx_http_internal_redirect(r, &uri, &args);\n    }\n    if (uri.len && uri.data[0] == \'@\') {\n        return ngx_http_named_location(r, &uri);\n    }\n    location = ngx_list_push(&r->headers_out.headers);\n    if (location == NULL) {\n        return NGX_ERROR;\n    }\n    if (overwrite != NGX_HTTP_MOVED_PERMANENTLY\n        && overwrite != NGX_HTTP_MOVED_TEMPORARILY\n        && overwrite != NGX_HTTP_SEE_OTHER\n        && overwrite != NGX_HTTP_TEMPORARY_REDIRECT\n        && overwrite != NGX_HTTP_PERMANENT_REDIRECT)\n    {\n        r->err_status = NGX_HTTP_MOVED_TEMPORARILY;\n    }\n    location->hash = 1;\n    ngx_str_set(&location->key, "Location");\n    location->value = uri;\n    ngx_http_clear_location(r);\n    r->headers_out.location = location;\n    clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);\n    if (clcf->msie_refresh && r->headers_in.msie) {\n        return ngx_http_send_refresh(r);\n    }\n    return ngx_http_send_special_response(r, clcf, r->err_status\n                                                   - NGX_HTTP_MOVED_PERMANENTLY\n                                                   + NGX_HTTP_OFF_3XX);\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}', "void\nngx_http_set_exten(ngx_http_request_t *r)\n{\n    ngx_int_t  i;\n    ngx_str_null(&r->exten);\n    for (i = r->uri.len - 1; i > 1; i--) {\n        if (r->uri.data[i] == '.' && r->uri.data[i - 1] != '/') {\n            r->exten.len = r->uri.len - i - 1;\n            r->exten.data = &r->uri.data[i + 1];\n            return;\n        } else if (r->uri.data[i] == '/') {\n            return;\n        }\n    }\n    return;\n}"]