Hi Maxim, Thank you so much for your explaination.
I have another question. If i have an empty string in my payload, it skips the phase handler completely. Example: curl -X POST http://localhost/proxy/profile/alice/comment -d '' -H 'Content-Type: application/json' the flag "-d ''" I do doing it at NGX_HTTP_ACCESS_PHASE in the handler. It seems that if "content_length = 0", it skips the access phase handler as well? Does this have to do with what we discussed? On Fri, Jan 12, 2024 at 5:59 AM Maxim Dounin <mdou...@mdounin.ru> wrote: > > Hello! > > On Fri, Jan 12, 2024 at 03:26:39AM +0800, Muhammad Nuzaihan wrote: > > > Hi Maxim, > > > > After searching the archives, I found the solution which you had > > answered before: > > https://www.ruby-forum.com/t/trouble-getting-the-request-body-of-a-http-post/180463/4 > > > > The code that reads the body is: > > rc = ngx_http_read_client_request_body(r, > > ngx_http_foo_body_handler); > > > > if (rc >= NGX_HTTP_SPECIAL_RESPONSE) { > > return rc; > > } > > > > Can i buy you coffee? > > You may want to start with basic examples and the dev guide, > specifically: > > https://nginx.org/en/docs/dev/development_guide.html#http_request_body > > Note though that reading the request body during phase processing, > in contrast to doing so in a content handler, requires special > precautions. In particular, you'll have to call > ngx_http_finalize_request(NGX_DONE) to ensure correct request > reference counting: > > https://hg.nginx.org/nginx/file/tip/src/http/modules/ngx_http_mirror_module.c#l120 > > Further, to resuming phase processing after reading the request > body you'll have to restore r->write_event_handler and call > ngx_http_core_run_phases(). See here in the mirror module for an > example: > > https://hg.nginx.org/nginx/file/tip/src/http/modules/ngx_http_mirror_module.c#l144 > > Hope this helps. > > -- > Maxim Dounin > http://mdounin.ru/ > _______________________________________________ > nginx-devel mailing list > nginx-devel@nginx.org > https://mailman.nginx.org/mailman/listinfo/nginx-devel _______________________________________________ nginx-devel mailing list nginx-devel@nginx.org https://mailman.nginx.org/mailman/listinfo/nginx-devel