当我启动服务器时
nghttpd --no-tls -v 8444
在另一个终端我发送一个请求
nghttp -v -y http://127.0.0.1:8444
我看到服务器看到我的请求并以 404 响应。是否可以配置为根据请求进行不同的响应?(我想实现一些基本逻辑,根据请求方法,路径不同的返回码)你能给我举个例子吗?让我们说GET
带有/dog
路径返回的请求200
,并发布请求返回404
当我启动服务器时
nghttpd --no-tls -v 8444
在另一个终端我发送一个请求
nghttp -v -y http://127.0.0.1:8444
我看到服务器看到我的请求并以 404 响应。是否可以配置为根据请求进行不同的响应?(我想实现一些基本逻辑,根据请求方法,路径不同的返回码)你能给我举个例子吗?让我们说GET
带有/dog
路径返回的请求200
,并发布请求返回404
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).