Re: processing a request without body

2024-01-13 Thread Maxim Dounin
Hello! On Sat, Jan 13, 2024 at 03:11:11PM +0800, Muhammad Nuzaihan wrote: > Hi Maxim, > > I did enable debug logs before i posted the question. > > With json payload, my code is executed right after doing malloc and > "http request body content length filter". > > Without a json payload, it do

Re: processing a request without body

2024-01-12 Thread Muhammad Nuzaihan
Hi Maxim, I've verified that even with "curl -X POST http://localhost/proxy/profile/alice/comment"; works. as below debug logs. 2024/01/13 15:19:44 [debug] 2452969#0: *20 rewrite phase: 0 2024/01/13 15:19:44 [debug] 2452969#0: *20 test location: "/" 2024/01/13 15:19:44 [debug] 2452969#0: *20 test

Re: processing a request without body

2024-01-12 Thread Muhammad Nuzaihan
Hi Maxim, (added some info about URL) I did enable debug logs before i posted the question. With json payload, my code is executed right after doing malloc and "http request body content length filter". Without a json payload, it doesn't execute my request validation.That's why i thought it migh

Re: processing a request without body

2024-01-12 Thread Muhammad Nuzaihan
Hi Maxim, I did enable debug logs before i posted the question. With json payload, my code is executed right after doing malloc and "http request body content length filter". Without a json payload, it doesn't execute my request validation.That's why i thought it might be due to content length i

Re: processing a request without body

2024-01-12 Thread Maxim Dounin
Hello! On Fri, Jan 12, 2024 at 10:17:42PM +0800, Muhammad Nuzaihan wrote: > 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/pro

Re: processing a request without body

2024-01-12 Thread Muhammad Nuzaihan
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 i

Re: processing a request without body

2024-01-11 Thread Maxim Dounin
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

Re: processing a request without body

2024-01-11 Thread Muhammad Nuzaihan
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_f

Re: processing a request without body

2024-01-10 Thread Muhammad Nuzaihan
Hi Maxim, Sorry for asking too many questions. I did looked at he mirror module and i couldn't find the code which reads the body (from what i understand i need a ngx_chain_t type of value to build the request body from buffer) https://github.com/nginx/nginx/blob/master/src/http/modules/ngx_http_

Re: processing a request without body

2023-12-20 Thread Maxim Dounin
Hello! On Tue, Dec 19, 2023 at 10:11:04PM +0800, Muhammad Nuzaihan wrote: > Thanks Maxim, Vasility, > > The problem i was going to solve is to i needed to run my specific > function that takes the data of request URL path, Headers and request > body and determine and validate that all that data

Re: processing a request without body

2023-12-19 Thread Muhammad Nuzaihan
Thanks Maxim, Vasility, The problem i was going to solve is to i needed to run my specific function that takes the data of request URL path, Headers and request body and determine and validate that all that data is correct before sending upstream, or else i would deny the request with 4xx code er

Re: processing a request without body

2023-12-13 Thread Vasiliy Soshnikov
Sorry I'm bad. I understood that header filters won't help you. Use the ACCESS PHASE handler, it should work fine for you. On Wed, Dec 13, 2023 at 10:57 PM Vasiliy Soshnikov < vasiliy.soshni...@gmail.com> wrote: > Hello, > > > Is there something similar done before? > I'm thinking that you would

Re: processing a request without body

2023-12-13 Thread Vasiliy Soshnikov
Hello, > Is there something similar done before? I'm thinking that you would like to test the incoming path and execute some logic. You could use a header filter for that and also you could keep a body filter for handling the request body. Also pls take a look into PHASEs, I'm thinking you could

Re: processing a request without body

2023-12-13 Thread Maxim Dounin
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 >

Re: processing a request without body

2023-12-13 Thread Muhammad Nuzaihan
Hi, Sorry about the previous email. I meant ngx_http_top_request_body_filter is not executed whenever there is no body. Thank you, Muhammad Nuzaihan On Wed, Dec 13, 2023 at 3:55 PM Muhammad Nuzaihan wrote: > > Hi, > > I need to process requests with only URI path (without body) for a module. >