Got "http reading blocked" on second request with same connection

frdcybermatrix nginx-forum at forum.nginx.org
Tue Nov 9 23:40:01 UTC 2021


Hi I'm having problem with my custom nginx module.
I created nginx module to detect wether the request is authorized or not,
and I need to check request body. So I use ngx_http_read_client_request_body
in NGX_HTTP_ACCESS_PHASE.
Modules work perfectly on one request at a time. For example: 'curl -v
localhost'
But the problem happen when second request happen using same connection. For
example: 'curl -v localhost localhost'.

When I try to debug I got  "http reading blocked". But when I remove
ngx_http_read_client_request_body, and leave body empty, it's work

static ngx_int_t
ngx_http_ai_inspect_handler(ngx_http_request_t *r)
{
    ngx_chain_t  *in;
    ngx_http_read_client_request_body(r, ngx_http_ai_inspect_post_handler);
    off_t len = 0;
    if (r->request_body != NULL) {
        for (in = r->request_body->bufs; in; in = in->next) {
            len += ngx_buf_size(in->buf);
        }
    }

}

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,292785,292785#msg-292785



More information about the nginx mailing list