src/http/ngx_http_request.c:1107: error: Buffer Overrun L3
  Offset: [2, +oo] Size: [0, +oo] by call to `ngx_http_process_request_header`.

src/http/ngx_http_request.c:1105:13: Assignment
1103.             r->request_length += r->header_in->pos - r->header_in->start;
1104. 
1105.             r->http_state = NGX_HTTP_PROCESS_REQUEST_STATE;
                  ^
1106. 
1107.             rc = ngx_http_process_request_header(r);

src/http/ngx_http_request.c:1107:18: Call
1105.             r->http_state = NGX_HTTP_PROCESS_REQUEST_STATE;
1106. 
1107.             rc = ngx_http_process_request_header(r);
                       ^
1108. 
1109.             if (rc != NGX_OK) {

src/http/ngx_http_request.c:1525:1: Parameter `r->http_connection->nfree`
  1523. 
  1524. 
  1525. static ngx_int_t
        ^
  1526. ngx_http_process_request_header(ngx_http_request_t *r)
  1527. {

src/http/ngx_http_request.c:1532:9: Call
  1530.         == NGX_ERROR)
  1531.     {
  1532.         ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
                ^
  1533.         return NGX_ERROR;
  1534.     }

src/http/ngx_http_request.c:1882:1: Parameter `r->http_connection->nfree`
    1880. 
    1881. 
    1882. void
          ^
    1883. ngx_http_finalize_request(ngx_http_request_t *r, ngx_int_t rc)
    1884. {

src/http/ngx_http_request.c:2071:5: Call
    2069.     }
    2070. 
    2071.     ngx_http_finalize_connection(r);
              ^
    2072. }
    2073. 

src/http/ngx_http_request.c:2135:1: Parameter `r->http_connection->nfree`
      2133. 
      2134. 
      2135. static void
            ^
      2136. ngx_http_finalize_connection(ngx_http_request_t *r)
      2137. {

src/http/ngx_http_request.c:2163:9: Call
      2161.          && clcf->keepalive_timeout > 0)
      2162.     {
      2163.         ngx_http_set_keepalive(r);
                    ^
      2164.         return;
      2165.     }

src/http/ngx_http_request.c:2402:1: <Offset trace>
2400. 
2401. 
2402. static void
      ^
2403. ngx_http_set_keepalive(ngx_http_request_t *r)
2404. {

src/http/ngx_http_request.c:2402:1: Parameter `r->http_connection->nfree`
        2400. 
        2401. 
        2402. static void
              ^
        2403. ngx_http_set_keepalive(ngx_http_request_t *r)
        2404. {

src/http/ngx_http_request.c:2402:1: <Length trace>
2400. 
2401. 
2402. static void
      ^
2403. ngx_http_set_keepalive(ngx_http_request_t *r)
2404. {

src/http/ngx_http_request.c:2402:1: Parameter `*r->http_connection->free`
        2400. 
        2401. 
        2402. static void
              ^
        2403. ngx_http_set_keepalive(ngx_http_request_t *r)
        2404. {

src/http/ngx_http_request.c:2461:17: Array access: Offset: [2, +oo] Size: [0, +oo] by call to `ngx_http_process_request_header` 
        2459.             for (i = 0; i < hc->nbusy - 1; i++) {
        2460.                 f = hc->busy[i];
        2461.                 hc->free[hc->nfree++] = f;
                              ^
        2462.                 f->pos = f->start;
        2463.                 f->last = f->start;

static void
ngx_http_set_keepalive(ngx_http_request_t *r)
{
    int                        tcp_nodelay;
    ngx_int_t                  i;
    ngx_buf_t                 *b, *f;
    ngx_event_t               *rev, *wev;
    ngx_connection_t          *c;
    ngx_http_connection_t     *hc;
    ngx_http_core_srv_conf_t  *cscf;
    ngx_http_core_loc_conf_t  *clcf;
    c = r->connection;
    rev = c->read;
    clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
    ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "set http keepalive handler");
    if (r->discard_body) {
        r->write_event_handler = ngx_http_request_empty_handler;
        r->lingering_time = ngx_time() + (time_t) (clcf->lingering_time / 1000);
        ngx_add_timer(rev, clcf->lingering_timeout);
        return;
    }
    c->log->action = "closing request";
    hc = r->http_connection;
    b = r->header_in;
    if (b->pos < b->last) {
        if (b != c->buffer) {
            cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module);
            if (hc->free == NULL) {
                hc->free = ngx_palloc(c->pool,
                  cscf->large_client_header_buffers.num * sizeof(ngx_buf_t *));
                if (hc->free == NULL) {
                    ngx_http_close_request(r, 0);
                    return;
                }
            }
            for (i = 0; i < hc->nbusy - 1; i++) {
                f = hc->busy[i];
                hc->free[hc->nfree++] = f;
                f->pos = f->start;
                f->last = f->start;
            }
            hc->busy[0] = b;
            hc->nbusy = 1;
        }
    }
    r->keepalive = 0;
    ngx_http_free_request(r, 0);
    c->data = hc;
    ngx_add_timer(rev, clcf->keepalive_timeout);
    if (ngx_handle_read_event(rev, 0) != NGX_OK) {
        ngx_http_close_connection(c);
        return;
    }
    wev = c->write;
    wev->handler = ngx_http_empty_handler;
    if (b->pos < b->last) {
        ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "pipelined request");
#if (NGX_STAT_STUB)
        (void) ngx_atomic_fetch_add(ngx_stat_reading, 1);
#endif
        hc->pipeline = 1;
        c->log->action = "reading client pipelined request line";
        rev->handler = ngx_http_init_request;
        ngx_post_event(rev, &ngx_posted_events);
        return;
    }
    hc->pipeline = 0;
    if (ngx_pfree(c->pool, r) == NGX_OK) {
        hc->request = NULL;
    }
    b = c->buffer;
    if (ngx_pfree(c->pool, b->start) == NGX_OK) {
        b->pos = NULL;
    } else {
        b->pos = b->start;
        b->last = b->start;
    }
    ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0, "hc free: %p %d",
                   hc->free, hc->nfree);
    if (hc->free) {
        for (i = 0; i < hc->nfree; i++) {
            ngx_pfree(c->pool, hc->free[i]->start);
            hc->free[i] = NULL;
        }
        hc->nfree = 0;
    }
    ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0, "hc busy: %p %d",
                   hc->busy, hc->nbusy);
    if (hc->busy) {
        for (i = 0; i < hc->nbusy; i++) {
            ngx_pfree(c->pool, hc->busy[i]->start);
            hc->busy[i] = NULL;
        }
        hc->nbusy = 0;
    }
#if (NGX_HTTP_SSL)
    if (c->ssl) {
        ngx_ssl_free_buffer(c);
    }
#endif
    rev->handler = ngx_http_keepalive_handler;
    if (wev->active && (ngx_event_flags & NGX_USE_LEVEL_EVENT)) {
        if (ngx_del_event(wev, NGX_WRITE_EVENT, 0) != NGX_OK) {
            ngx_http_close_connection(c);
            return;
        }
    }
    c->log->action = "keepalive";
    if (c->tcp_nopush == NGX_TCP_NOPUSH_SET) {
        if (ngx_tcp_push(c->fd) == -1) {
            ngx_connection_error(c, ngx_socket_errno, ngx_tcp_push_n " failed");
            ngx_http_close_connection(c);
            return;
        }
        c->tcp_nopush = NGX_TCP_NOPUSH_UNSET;
        tcp_nodelay = ngx_tcp_nodelay_and_tcp_nopush ? 1 : 0;
    } else {
        tcp_nodelay = 1;
    }
    if (tcp_nodelay
        && clcf->tcp_nodelay
        && c->tcp_nodelay == NGX_TCP_NODELAY_UNSET)
    {
        ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "tcp_nodelay");
        if (setsockopt(c->fd, IPPROTO_TCP, TCP_NODELAY,
                       (const void *) &tcp_nodelay, sizeof(int))
            == -1)
        {
#if (NGX_SOLARIS)
            c->log_error = NGX_ERROR_IGNORE_EINVAL;
#endif
            ngx_connection_error(c, ngx_socket_errno,
                                 "setsockopt(TCP_NODELAY) failed");
            c->log_error = NGX_ERROR_INFO;
            ngx_http_close_connection(c);
            return;
        }
        c->tcp_nodelay = NGX_TCP_NODELAY_SET;
    }
#if 0
    r->http_state = NGX_HTTP_KEEPALIVE_STATE;
#endif
    c->idle = 1;
    ngx_reusable_connection(c, 1);
    if (rev->ready) {
        ngx_post_event(rev, &ngx_posted_events);
    }
}
['static void\nngx_http_process_request_headers(ngx_event_t *rev)\n{\n    u_char                     *p;\n    size_t                      len;\n    ssize_t                     n;\n    ngx_int_t                   rc, rv;\n    ngx_table_elt_t            *h;\n    ngx_connection_t           *c;\n    ngx_http_header_t          *hh;\n    ngx_http_request_t         *r;\n    ngx_http_core_srv_conf_t   *cscf;\n    ngx_http_core_main_conf_t  *cmcf;\n    c = rev->data;\n    r = c->data;\n    ngx_log_debug0(NGX_LOG_DEBUG_HTTP, rev->log, 0,\n                   "http process request header line");\n    if (rev->timedout) {\n        ngx_log_error(NGX_LOG_INFO, c->log, NGX_ETIMEDOUT, "client timed out");\n        c->timedout = 1;\n        ngx_http_close_request(r, NGX_HTTP_REQUEST_TIME_OUT);\n        return;\n    }\n    cmcf = ngx_http_get_module_main_conf(r, ngx_http_core_module);\n    cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module);\n    rc = NGX_AGAIN;\n    for ( ;; ) {\n        if (rc == NGX_AGAIN) {\n            if (r->header_in->pos == r->header_in->end) {\n                rv = ngx_http_alloc_large_header_buffer(r, 0);\n                if (rv == NGX_ERROR) {\n                    ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);\n                    return;\n                }\n                if (rv == NGX_DECLINED) {\n                    p = r->header_name_start;\n                    r->lingering_close = 1;\n                    if (p == NULL) {\n                        ngx_log_error(NGX_LOG_INFO, c->log, 0,\n                                      "client sent too large request");\n                        ngx_http_finalize_request(r,\n                                            NGX_HTTP_REQUEST_HEADER_TOO_LARGE);\n                        return;\n                    }\n                    len = r->header_in->end - p;\n                    if (len > NGX_MAX_ERROR_STR - 300) {\n                        len = NGX_MAX_ERROR_STR - 300;\n                        p[len++] = \'.\'; p[len++] = \'.\'; p[len++] = \'.\';\n                    }\n                    ngx_log_error(NGX_LOG_INFO, c->log, 0,\n                                  "client sent too long header line: \\"%*s\\"",\n                                  len, r->header_name_start);\n                    ngx_http_finalize_request(r,\n                                            NGX_HTTP_REQUEST_HEADER_TOO_LARGE);\n                    return;\n                }\n            }\n            n = ngx_http_read_request_header(r);\n            if (n == NGX_AGAIN || n == NGX_ERROR) {\n                return;\n            }\n        }\n        rc = ngx_http_parse_header_line(r, r->header_in,\n                                        cscf->underscores_in_headers);\n        if (rc == NGX_OK) {\n            if (r->invalid_header && cscf->ignore_invalid_headers) {\n                ngx_log_error(NGX_LOG_INFO, c->log, 0,\n                              "client sent invalid header line: \\"%*s\\"",\n                              r->header_end - r->header_name_start,\n                              r->header_name_start);\n                continue;\n            }\n            h = ngx_list_push(&r->headers_in.headers);\n            if (h == NULL) {\n                ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);\n                return;\n            }\n            h->hash = r->header_hash;\n            h->key.len = r->header_name_end - r->header_name_start;\n            h->key.data = r->header_name_start;\n            h->key.data[h->key.len] = \'\\0\';\n            h->value.len = r->header_end - r->header_start;\n            h->value.data = r->header_start;\n            h->value.data[h->value.len] = \'\\0\';\n            h->lowcase_key = ngx_pnalloc(r->pool, h->key.len);\n            if (h->lowcase_key == NULL) {\n                ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);\n                return;\n            }\n            if (h->key.len == r->lowcase_index) {\n                ngx_memcpy(h->lowcase_key, r->lowcase_header, h->key.len);\n            } else {\n                ngx_strlow(h->lowcase_key, h->key.data, h->key.len);\n            }\n            hh = ngx_hash_find(&cmcf->headers_in_hash, h->hash,\n                               h->lowcase_key, h->key.len);\n            if (hh && hh->handler(r, h, hh->offset) != NGX_OK) {\n                return;\n            }\n            ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,\n                           "http header: \\"%V: %V\\"",\n                           &h->key, &h->value);\n            continue;\n        }\n        if (rc == NGX_HTTP_PARSE_HEADER_DONE) {\n            ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,\n                           "http header done");\n            r->request_length += r->header_in->pos - r->header_in->start;\n            r->http_state = NGX_HTTP_PROCESS_REQUEST_STATE;\n            rc = ngx_http_process_request_header(r);\n            if (rc != NGX_OK) {\n                return;\n            }\n            ngx_http_process_request(r);\n            return;\n        }\n        if (rc == NGX_AGAIN) {\n            continue;\n        }\n        ngx_log_error(NGX_LOG_INFO, c->log, 0,\n                      "client sent invalid header line: \\"%*s\\\\r...\\"",\n                      r->header_end - r->header_name_start,\n                      r->header_name_start);\n        ngx_http_finalize_request(r, NGX_HTTP_BAD_REQUEST);\n        return;\n    }\n}', 'static ngx_int_t\nngx_http_process_request_header(ngx_http_request_t *r)\n{\n    if (ngx_http_find_virtual_server(r, r->headers_in.server.data,\n                                     r->headers_in.server.len)\n        == NGX_ERROR)\n    {\n        ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);\n        return NGX_ERROR;\n    }\n    if (r->headers_in.host == NULL && r->http_version > NGX_HTTP_VERSION_10) {\n        ngx_log_error(NGX_LOG_INFO, r->connection->log, 0,\n                   "client sent HTTP/1.1 request without \\"Host\\" header");\n        ngx_http_finalize_request(r, NGX_HTTP_BAD_REQUEST);\n        return NGX_ERROR;\n    }\n    if (r->headers_in.content_length) {\n        r->headers_in.content_length_n =\n                            ngx_atoof(r->headers_in.content_length->value.data,\n                                      r->headers_in.content_length->value.len);\n        if (r->headers_in.content_length_n == NGX_ERROR) {\n            ngx_log_error(NGX_LOG_INFO, r->connection->log, 0,\n                          "client sent invalid \\"Content-Length\\" header");\n            ngx_http_finalize_request(r, NGX_HTTP_LENGTH_REQUIRED);\n            return NGX_ERROR;\n        }\n    }\n    if (r->method & NGX_HTTP_PUT && r->headers_in.content_length_n == -1) {\n        ngx_log_error(NGX_LOG_INFO, r->connection->log, 0,\n                  "client sent %V method without \\"Content-Length\\" header",\n                  &r->method_name);\n        ngx_http_finalize_request(r, NGX_HTTP_LENGTH_REQUIRED);\n        return NGX_ERROR;\n    }\n    if (r->method & NGX_HTTP_TRACE) {\n        ngx_log_error(NGX_LOG_INFO, r->connection->log, 0,\n                      "client sent TRACE method");\n        ngx_http_finalize_request(r, NGX_HTTP_NOT_ALLOWED);\n        return NGX_ERROR;\n    }\n    if (r->headers_in.transfer_encoding\n        && ngx_strcasestrn(r->headers_in.transfer_encoding->value.data,\n                           "chunked", 7 - 1))\n    {\n        ngx_log_error(NGX_LOG_INFO, r->connection->log, 0,\n                      "client sent \\"Transfer-Encoding: chunked\\" header");\n        ngx_http_finalize_request(r, NGX_HTTP_LENGTH_REQUIRED);\n        return NGX_ERROR;\n    }\n    if (r->headers_in.connection_type == NGX_HTTP_CONNECTION_KEEP_ALIVE) {\n        if (r->headers_in.keep_alive) {\n            r->headers_in.keep_alive_n =\n                            ngx_atotm(r->headers_in.keep_alive->value.data,\n                                      r->headers_in.keep_alive->value.len);\n        }\n    }\n    return NGX_OK;\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: %d, \\"%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        return;\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        if (r->main->blocked) {\n            r->write_event_handler = ngx_http_request_finalizer;\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        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#if (NGX_DEBUG)\n        if (r != c->data) {\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        }\n#endif\n        pr = r->parent;\n        if (r == c->data) {\n            r->main->count--;\n            if (!r->logged) {\n                clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);\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            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 || r->blocked) {\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->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 void\nngx_http_finalize_connection(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 (r->main->count != 1) {\n        if (r->discard_body) {\n            r->read_event_handler = ngx_http_discarded_request_body_handler;\n            ngx_add_timer(r->connection->read, clcf->lingering_timeout);\n            if (r->lingering_time == 0) {\n                r->lingering_time = ngx_time()\n                                      + (time_t) (clcf->lingering_time / 1000);\n            }\n        }\n        ngx_http_close_request(r, 0);\n        return;\n    }\n    if (!ngx_terminate\n         && !ngx_exiting\n         && r->keepalive\n         && clcf->keepalive_timeout > 0)\n    {\n        ngx_http_set_keepalive(r);\n        return;\n    }\n    if (clcf->lingering_close == NGX_HTTP_LINGERING_ALWAYS\n        || (clcf->lingering_close == NGX_HTTP_LINGERING_ON\n            && (r->lingering_close\n                || r->header_in->pos < r->header_in->last\n                || r->connection->read->ready)))\n    {\n        ngx_http_set_lingering_close(r);\n        return;\n    }\n    ngx_http_close_request(r, 0);\n}', 'static void\nngx_http_set_keepalive(ngx_http_request_t *r)\n{\n    int                        tcp_nodelay;\n    ngx_int_t                  i;\n    ngx_buf_t                 *b, *f;\n    ngx_event_t               *rev, *wev;\n    ngx_connection_t          *c;\n    ngx_http_connection_t     *hc;\n    ngx_http_core_srv_conf_t  *cscf;\n    ngx_http_core_loc_conf_t  *clcf;\n    c = r->connection;\n    rev = c->read;\n    clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);\n    ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "set http keepalive handler");\n    if (r->discard_body) {\n        r->write_event_handler = ngx_http_request_empty_handler;\n        r->lingering_time = ngx_time() + (time_t) (clcf->lingering_time / 1000);\n        ngx_add_timer(rev, clcf->lingering_timeout);\n        return;\n    }\n    c->log->action = "closing request";\n    hc = r->http_connection;\n    b = r->header_in;\n    if (b->pos < b->last) {\n        if (b != c->buffer) {\n            cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module);\n            if (hc->free == NULL) {\n                hc->free = ngx_palloc(c->pool,\n                  cscf->large_client_header_buffers.num * sizeof(ngx_buf_t *));\n                if (hc->free == NULL) {\n                    ngx_http_close_request(r, 0);\n                    return;\n                }\n            }\n            for (i = 0; i < hc->nbusy - 1; i++) {\n                f = hc->busy[i];\n                hc->free[hc->nfree++] = f;\n                f->pos = f->start;\n                f->last = f->start;\n            }\n            hc->busy[0] = b;\n            hc->nbusy = 1;\n        }\n    }\n    r->keepalive = 0;\n    ngx_http_free_request(r, 0);\n    c->data = hc;\n    ngx_add_timer(rev, clcf->keepalive_timeout);\n    if (ngx_handle_read_event(rev, 0) != NGX_OK) {\n        ngx_http_close_connection(c);\n        return;\n    }\n    wev = c->write;\n    wev->handler = ngx_http_empty_handler;\n    if (b->pos < b->last) {\n        ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "pipelined request");\n#if (NGX_STAT_STUB)\n        (void) ngx_atomic_fetch_add(ngx_stat_reading, 1);\n#endif\n        hc->pipeline = 1;\n        c->log->action = "reading client pipelined request line";\n        rev->handler = ngx_http_init_request;\n        ngx_post_event(rev, &ngx_posted_events);\n        return;\n    }\n    hc->pipeline = 0;\n    if (ngx_pfree(c->pool, r) == NGX_OK) {\n        hc->request = NULL;\n    }\n    b = c->buffer;\n    if (ngx_pfree(c->pool, b->start) == NGX_OK) {\n        b->pos = NULL;\n    } else {\n        b->pos = b->start;\n        b->last = b->start;\n    }\n    ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0, "hc free: %p %d",\n                   hc->free, hc->nfree);\n    if (hc->free) {\n        for (i = 0; i < hc->nfree; i++) {\n            ngx_pfree(c->pool, hc->free[i]->start);\n            hc->free[i] = NULL;\n        }\n        hc->nfree = 0;\n    }\n    ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0, "hc busy: %p %d",\n                   hc->busy, hc->nbusy);\n    if (hc->busy) {\n        for (i = 0; i < hc->nbusy; i++) {\n            ngx_pfree(c->pool, hc->busy[i]->start);\n            hc->busy[i] = NULL;\n        }\n        hc->nbusy = 0;\n    }\n#if (NGX_HTTP_SSL)\n    if (c->ssl) {\n        ngx_ssl_free_buffer(c);\n    }\n#endif\n    rev->handler = ngx_http_keepalive_handler;\n    if (wev->active && (ngx_event_flags & NGX_USE_LEVEL_EVENT)) {\n        if (ngx_del_event(wev, NGX_WRITE_EVENT, 0) != NGX_OK) {\n            ngx_http_close_connection(c);\n            return;\n        }\n    }\n    c->log->action = "keepalive";\n    if (c->tcp_nopush == NGX_TCP_NOPUSH_SET) {\n        if (ngx_tcp_push(c->fd) == -1) {\n            ngx_connection_error(c, ngx_socket_errno, ngx_tcp_push_n " failed");\n            ngx_http_close_connection(c);\n            return;\n        }\n        c->tcp_nopush = NGX_TCP_NOPUSH_UNSET;\n        tcp_nodelay = ngx_tcp_nodelay_and_tcp_nopush ? 1 : 0;\n    } else {\n        tcp_nodelay = 1;\n    }\n    if (tcp_nodelay\n        && clcf->tcp_nodelay\n        && c->tcp_nodelay == NGX_TCP_NODELAY_UNSET)\n    {\n        ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "tcp_nodelay");\n        if (setsockopt(c->fd, IPPROTO_TCP, TCP_NODELAY,\n                       (const void *) &tcp_nodelay, sizeof(int))\n            == -1)\n        {\n#if (NGX_SOLARIS)\n            c->log_error = NGX_ERROR_IGNORE_EINVAL;\n#endif\n            ngx_connection_error(c, ngx_socket_errno,\n                                 "setsockopt(TCP_NODELAY) failed");\n            c->log_error = NGX_ERROR_INFO;\n            ngx_http_close_connection(c);\n            return;\n        }\n        c->tcp_nodelay = NGX_TCP_NODELAY_SET;\n    }\n#if 0\n    r->http_state = NGX_HTTP_KEEPALIVE_STATE;\n#endif\n    c->idle = 1;\n    ngx_reusable_connection(c, 1);\n    if (rev->ready) {\n        ngx_post_event(rev, &ngx_posted_events);\n    }\n}']