processing a request without body

Maxim Dounin mdounin at mdounin.ru
Wed Dec 13 19:16:33 UTC 2023


Hello!

On Wed, Dec 13, 2023 at 03:55:56PM +0800, Muhammad Nuzaihan wrote:

> I need to process requests with only URI path (without body) for a module.
> 
> It seems ngx_http_request_body_filter_pt is *not* executed whenever
> there is a request without a body (it looked like it bypassed without
> request body) and only ngx_http_output_body_filter_pt  part of the
> code is executed.
> 
> For example i do a request curl curl like this:
> 
> curl -vvvv -X POST http://localhost:8080/proxy/profile/alice/comment
> 
> and i need to validate /proxy/profile/alice/comment in my module and
> there is no http headers and no body. Only URI path.

When reading an HTTP request, nginx reads the request line and 
request headers, and then starts request processing by passing it 
through as sequence of request processing phases - in each phase, 
corresponding handlers are called.  The request body filters are 
only called if there is a request body, and some handler actually 
requested reading of the request body - so it's expected these are 
not called if there is no request body.

If you want to handle request based on the request line and the 
request headers, consider using appropriate phase handler, see

https://nginx.org/en/docs/dev/development_guide.html#http_phases

and the source code for details.

-- 
Maxim Dounin
http://mdounin.ru/


More information about the nginx-devel mailing list