static int stream_reqbody_read(proxy_http_req_t *req, apr_bucket_brigade *bb,
                               int nonblocking)
{
    request_rec *r = req->r;
    proxy_conn_rec *p_conn = req->backend;
    apr_bucket_alloc_t *bucket_alloc = req->bucket_alloc;
    apr_read_type_e block = nonblocking ? APR_NONBLOCK_READ : APR_BLOCK_READ;
    apr_status_t status;
    int rv;
    for (;;) {
        status = ap_get_brigade(r->input_filters, bb, AP_MODE_READBYTES,
                                block, HUGE_STRING_LEN);
        if (block == APR_BLOCK_READ
                || (!APR_STATUS_IS_EAGAIN(status)
                    && (status != APR_SUCCESS || !APR_BRIGADE_EMPTY(bb)))) {
            break;
        }
        apr_brigade_cleanup(bb);
        rv = ap_proxy_pass_brigade(bucket_alloc, r, p_conn, req->origin, bb, 1);
        if (rv != OK) {
            return rv;
        }
        block = APR_BLOCK_READ;
    }
    if (status != APR_SUCCESS) {
        conn_rec *c = r->connection;
        ap_log_rerror(APLOG_MARK, APLOG_ERR, status, r, APLOGNO(02608)
                      "read request body failed to %pI (%s)"
                      " from %s (%s)", p_conn->addr,
                      p_conn->hostname ? p_conn->hostname: "",
                      c->client_ip, c->remote_host ? c->remote_host: "");
        return ap_map_http_request_error(status, HTTP_BAD_REQUEST);
    }
    return OK;
}
['static int stream_reqbody_read(proxy_http_req_t *req, apr_bucket_brigade *bb,\n                               int nonblocking)\n{\n    request_rec *r = req->r;\n    proxy_conn_rec *p_conn = req->backend;\n    apr_bucket_alloc_t *bucket_alloc = req->bucket_alloc;\n    apr_read_type_e block = nonblocking ? APR_NONBLOCK_READ : APR_BLOCK_READ;\n    apr_status_t status;\n    int rv;\n    for (;;) {\n        status = ap_get_brigade(r->input_filters, bb, AP_MODE_READBYTES,\n                                block, HUGE_STRING_LEN);\n        if (block == APR_BLOCK_READ\n                || (!APR_STATUS_IS_EAGAIN(status)\n                    && (status != APR_SUCCESS || !APR_BRIGADE_EMPTY(bb)))) {\n            break;\n        }\n        apr_brigade_cleanup(bb);\n        rv = ap_proxy_pass_brigade(bucket_alloc, r, p_conn, req->origin, bb, 1);\n        if (rv != OK) {\n            return rv;\n        }\n        block = APR_BLOCK_READ;\n    }\n    if (status != APR_SUCCESS) {\n        conn_rec *c = r->connection;\n        ap_log_rerror(APLOG_MARK, APLOG_ERR, status, r, APLOGNO(02608)\n                      "read request body failed to %pI (%s)"\n                      " from %s (%s)", p_conn->addr,\n                      p_conn->hostname ? p_conn->hostname: "",\n                      c->client_ip, c->remote_host ? c->remote_host: "");\n        return ap_map_http_request_error(status, HTTP_BAD_REQUEST);\n    }\n    return OK;\n}']