Skip to content

[BUG] default method-not-allowed response misses HTTP header Allow: #240

@LeSpocky

Description

@LeSpocky

Prerequisites

Description

RFC 7231 states in section 6.5.5. 405 Method Not Allowed:

The 405 (Method Not Allowed) status code indicates that the method
received in the request-line is known by the origin server but not
supported by the target resource. The origin server MUST generate an
Allow header field in a 405 response containing a list of the target
resource's currently supported methods.

That Allow: header is not sent by libhttpserver.

Steps to Reproduce

  1. build with examples
  2. run examples/allowing_disallowing_methods
  3. send POST request, e.g. with curl -XPOST -v http://localhost:8080/hello
  4. inspect HTTP headers

Expected behavior: send that header based on allowed_methods member of class http_resource

Actual behavior: HTTP header Allow: is not sent

Reproduces how often: always, at least unless webserver is constructed with a custom method_not_allowed_resource.

Versions

  • OS version: Debian GNU/Linux 10 (buster)
  • libhttpserver version: 0.18.2-22-g263f2bd (current master)
  • libmicrohttpd version: 0.9.62 (Debian package)

Additional Information

curl output (tail):

* Connected to localhost (127.0.0.1) port 8080 (#0)
> POST /hello HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.64.0
> Accept: */*
> 
< HTTP/1.1 405 Method Not Allowed
< Connection: Keep-Alive
< Content-Length: 18
< Content-Type: text/plain
< Date: Tue, 09 Nov 2021 13:16:31 GMT
< 
* Connection #0 to host localhost left intact
Method not Allowed

Example and explanation for allow header: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Allow

Metadata

Metadata

Assignees

Labels

bugConfirmed bugs or reports that are very likely to be bugs.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions