static ngx_int_t
ngx_http_upstream_send_request_body(ngx_http_request_t *r,
    ngx_http_upstream_t *u, ngx_uint_t do_write)
{
    int                        tcp_nodelay;
    ngx_int_t                  rc;
    ngx_chain_t               *out, *cl, *ln;
    ngx_connection_t          *c;
    ngx_http_core_loc_conf_t  *clcf;
    ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
                   "http upstream send request body");
    if (!r->request_body_no_buffering) {
       if (!u->request_sent) {
           u->request_sent = 1;
           out = u->request_bufs;
       } else {
           out = NULL;
       }
       return ngx_output_chain(&u->output, out);
    }
    if (!u->request_sent) {
        u->request_sent = 1;
        out = u->request_bufs;
        if (r->request_body->bufs) {
            for (cl = out; cl->next; cl = out->next) {   }
            cl->next = r->request_body->bufs;
            r->request_body->bufs = NULL;
        }
        c = u->peer.connection;
        clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
        if (clcf->tcp_nodelay && c->tcp_nodelay == NGX_TCP_NODELAY_UNSET) {
            ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "tcp_nodelay");
            tcp_nodelay = 1;
            if (setsockopt(c->fd, IPPROTO_TCP, TCP_NODELAY,
                           (const void *) &tcp_nodelay, sizeof(int)) == -1)
            {
                ngx_connection_error(c, ngx_socket_errno,
                                     "setsockopt(TCP_NODELAY) failed");
                return NGX_ERROR;
            }
            c->tcp_nodelay = NGX_TCP_NODELAY_SET;
        }
        r->read_event_handler = ngx_http_upstream_read_request_handler;
    } else {
        out = NULL;
    }
    for ( ;; ) {
        if (do_write) {
            rc = ngx_output_chain(&u->output, out);
            if (rc == NGX_ERROR) {
                return NGX_ERROR;
            }
            while (out) {
                ln = out;
                out = out->next;
                ngx_free_chain(r->pool, ln);
            }
            if (rc == NGX_OK && !r->reading_body) {
                break;
            }
        }
        if (r->reading_body) {
            rc = ngx_http_read_unbuffered_request_body(r);
            if (rc >= NGX_HTTP_SPECIAL_RESPONSE) {
                return rc;
            }
            out = r->request_body->bufs;
            r->request_body->bufs = NULL;
        }
        if (out == NULL) {
            rc = NGX_AGAIN;
            break;
        }
        do_write = 1;
    }
    if (!r->reading_body) {
        if (!u->store && !r->post_action && !u->conf->ignore_client_abort) {
            r->read_event_handler =
                                  ngx_http_upstream_rd_check_broken_connection;
        }
    }
    return rc;
}
['static ngx_int_t\nngx_http_upstream_send_request_body(ngx_http_request_t *r,\n    ngx_http_upstream_t *u, ngx_uint_t do_write)\n{\n    int                        tcp_nodelay;\n    ngx_int_t                  rc;\n    ngx_chain_t               *out, *cl, *ln;\n    ngx_connection_t          *c;\n    ngx_http_core_loc_conf_t  *clcf;\n    ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,\n                   "http upstream send request body");\n    if (!r->request_body_no_buffering) {\n       if (!u->request_sent) {\n           u->request_sent = 1;\n           out = u->request_bufs;\n       } else {\n           out = NULL;\n       }\n       return ngx_output_chain(&u->output, out);\n    }\n    if (!u->request_sent) {\n        u->request_sent = 1;\n        out = u->request_bufs;\n        if (r->request_body->bufs) {\n            for (cl = out; cl->next; cl = out->next) {   }\n            cl->next = r->request_body->bufs;\n            r->request_body->bufs = NULL;\n        }\n        c = u->peer.connection;\n        clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);\n        if (clcf->tcp_nodelay && c->tcp_nodelay == NGX_TCP_NODELAY_UNSET) {\n            ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "tcp_nodelay");\n            tcp_nodelay = 1;\n            if (setsockopt(c->fd, IPPROTO_TCP, TCP_NODELAY,\n                           (const void *) &tcp_nodelay, sizeof(int)) == -1)\n            {\n                ngx_connection_error(c, ngx_socket_errno,\n                                     "setsockopt(TCP_NODELAY) failed");\n                return NGX_ERROR;\n            }\n            c->tcp_nodelay = NGX_TCP_NODELAY_SET;\n        }\n        r->read_event_handler = ngx_http_upstream_read_request_handler;\n    } else {\n        out = NULL;\n    }\n    for ( ;; ) {\n        if (do_write) {\n            rc = ngx_output_chain(&u->output, out);\n            if (rc == NGX_ERROR) {\n                return NGX_ERROR;\n            }\n            while (out) {\n                ln = out;\n                out = out->next;\n                ngx_free_chain(r->pool, ln);\n            }\n            if (rc == NGX_OK && !r->reading_body) {\n                break;\n            }\n        }\n        if (r->reading_body) {\n            rc = ngx_http_read_unbuffered_request_body(r);\n            if (rc >= NGX_HTTP_SPECIAL_RESPONSE) {\n                return rc;\n            }\n            out = r->request_body->bufs;\n            r->request_body->bufs = NULL;\n        }\n        if (out == NULL) {\n            rc = NGX_AGAIN;\n            break;\n        }\n        do_write = 1;\n    }\n    if (!r->reading_body) {\n        if (!u->store && !r->post_action && !u->conf->ignore_client_abort) {\n            r->read_event_handler =\n                                  ngx_http_upstream_rd_check_broken_connection;\n        }\n    }\n    return rc;\n}']