Skip to content

plugin proxy_control does not work as expected #89

@mcdullbloom

Description

@mcdullbloom

**The plugin will not work as expected when a module has read request body in the phase before proxy_pass **
A similar one I mentioned in https://github.com/apache/apisix/issues/10379

I add log print below and plugin proxy_control set variable of request_body_no_buffering to 1 indeed.

static ngx_int_t
ngx_http_proxy_handler(ngx_http_request_t *r)
{
...
#if (NGX_HTTP_APISIX)

    if (!ngx_http_apisix_is_request_buffering(r, plcf->upstream.request_buffering)
#else
    if (!plcf->upstream.request_buffering

#endif
        && plcf->body_values == NULL && plcf->upstream.pass_request_body
        && (!r->headers_in.chunked
            || plcf->http_version == NGX_HTTP_VERSION_11))
    {
       // add log print
       ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
                      "========set request_body_no_buffering=======" );
        r->request_body_no_buffering = 1;
    }
...
ngx_int_t
ngx_http_read_client_request_body(ngx_http_request_t *r,
    ngx_http_client_body_handler_pt post_handler)
{
    size_t                     preread;
    ssize_t                    size;
    ngx_int_t                  rc;
    ngx_buf_t                 *b;
    ngx_chain_t                out;
    ngx_http_request_body_t   *rb;
    ngx_http_core_loc_conf_t  *clcf;

    r->main->count++;

    if (r != r->main || r->request_body || r->discard_body) {
        r->request_body_no_buffering = 0;      // if request body has been read before, set back to 0
        post_handler(r);
        return NGX_OK;
    }
...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions