Welcome! Log In Create A New Profile

Advanced

module which handles POST request help

Ben Mesander via nginx
September 18, 2023 11:28AM
I'm working on an nginx module which will handle POST requests. I've never
written an nginx module before, but I have worked on apache modules. My
goal is to have it do unbuffered reads and process the data being posted as
it arrives. Initially, I'm doing just a simple blocking read of the POST
body. I've simplified things down almost to the "hello world" level.

When I do a POST, my module gets called, but I get a 404 not found, I am
not sure why. I do see the file I post being uploaded and stored in a file
in the nginx temporary file area. I do not see an entry in the access log
showing the POST, again I am not sure why. How can I fix these things?

Source to my module:
https://github.com/benmesander/ngx-dashll-module/tree/main

Results of sending a POST request:

bmesander@o-bmesander-D093Y Downloads % curl -v -X POST -H "Content-Type:
application/json" -d @chrome-net-export-log.json http://www:80/upload

Note: Unnecessary use of -X or --request, POST is already inferred.

* Trying x.x.x.x:80...

* Connected to www (x.x.x.x) port 80 (#0)

> POST /upload HTTP/1.1

> Host: www

> User-Agent: curl/7.86.0

> Accept: */*

> Content-Type: application/json

> Content-Length: 777095

>

* We are completely uploaded and fine

* Mark bundle as not supporting multiuse

< HTTP/1.1 404 Not Found

< Server: nginx/1.25.3

< Date: Mon, 18 Sep 2023 15:11:35 GMT

< Content-Type: text/html

< Content-Length: 153

< Connection: keep-alive

<

<html>

<head><title>404 Not Found</title></head>

<body>

<center><h1>404 Not Found</h1></center>

<hr><center>nginx/1.25.3</center>

</body>

</html>

* Connection #0 to host www left intact

Here is how I am building nginx & my module:

auto/configure --with-debug --with-cc-opt="-fsanitize=address
-DNGX_DEBUG_PALLOC=1" --with-ld-opt="-fsanitize=address" --add-module=../
ngx-dashll-module

Thank you,
Ben

--

*Ben Mesander **C**ARDINAL**P**EAK*

(303) 570-1606 | Email <bmesander@cardinalpeak.com> | Web
http://www.cardinalpeak.com/ | Company Blog
http://www.cardinalpeak.com/blog | LinkedIn
https://www.linkedin.com/in/benmesander/
_______________________________________________
nginx mailing list
nginx@nginx.org
https://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

module which handles POST request help

Ben Mesander via nginx September 18, 2023 11:28AM

Re: module which handles POST request help

Maxim Dounin September 18, 2023 08:46PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 211
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready