I want to figure out which methods are supported on a resource.
use the [OPTIONS] method for this:
OPTIONS /my/resource HTTP/1.1 Host: example.org HTTP/1.1 200 OK Allow: HEAD,GET,DELETE,OPTIONS
Even though it's not defined, this method CAN return a message body. It will return an ALLOW header, that returns all the methods the current resource is capable of handling.
If resources require authentication, it is possible that OPTIONS returns more methods once you added authentication headers to the request.
OPTIONS /a/resource HTTP/1.1 Host: example.org HTTP/1.1 200 OK Allow: HEAD,GET,OPTIONS
OPTIONS /a/resource HTTP/1.1 Host: example.org Authentication: ..... HTTP/1.1 200 OK Allow: HEAD,GET,PUT,POST,DELETE,OPTIONS
另请参见
注意
- OPTIONS is not a very common implemented method.