Is calling ngx_http_discard_request_body() still necessary in modules only handle HTTP GETs ?

gzchenym nginx-forum at
Thu Jul 24 14:09:12 UTC 2014

Hi all:

    In nginx's native memcached module, I found that
ngx_http_discard_request_body() was called right after a statement that only
allow  GET/HEAD requests to pass through. 

For ref: src/http/modules/ngx_http_memcached_module.c

    if (!(r->method & (NGX_HTTP_GET|NGX_HTTP_HEAD))) {
        return NGX_HTTP_NOT_ALLOWED;

    rc = ngx_http_discard_request_body(r);

      However, in other places, such as (ngx_http_empty_gif_module) ,that
ngx_http_discard_request_body() function call was just missed. Usually HTTP
GET  reqeust should not have request body. So, what's the point of having
ngx_http_discard_request_body() in memcached module?   and which pattern
should I use?


Posted at Nginx Forum:,252022,252022#msg-252022

More information about the nginx mailing list