Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plugin proxy_control does not work as expected #89

Open
mcdullbloom opened this issue Mar 25, 2024 · 0 comments
Open

plugin proxy_control does not work as expected #89

mcdullbloom opened this issue Mar 25, 2024 · 0 comments

Comments

@mcdullbloom
Copy link

**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;
    }
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant