servercommand-line-interfacehttp2nghttp2

How can I configure nghttpd to response differently based on the request?


When I start a server with

nghttpd --no-tls -v 8444

And in another terminal I send a request

 nghttp -v -y http://127.0.0.1:8444

I see that the server saw my request and responded with 404. Is it possible to configure to respond differently based on the request? (I 'd like to implement some basic logic, different return codes based on request method, path) Can you show me an example for that? Lets say for GET request with /dog path return 200, and to post request return 404


Solution

  • I don't think this is possible. Nghttpd is a simple webserver to demonstrate the nghttp library and also useful for debugging HTTP/2, but it is not intended as a fully featured web server.

    As an aside, I would also question whether a POST should return 404 to a valid path. 404 is "Not Found" which is not right - the resource is found. Most web servers would return the same as a GET request for such a request (as does nghttpd).