I'm building a REST API and trying to return 405 Method Not Allowed for a particular route when a HEAD request comes in.
The rules say "The response MUST include an Allow header containing a list of valid methods for the requested resource."
However, the rules also say "the server MUST NOT return a message-body in the response."
So I'm constructing my HttpResponseMessage
with its Content
property null, but the only way I can supply an "Allow" header is as a content header. If I try to supply it as a header on the HttpResponseMessage
object instead of the HttpContent
object, I get an error:
Misused header name. Make sure request headers are used with HttpRequestMessage, response headers with HttpResponseMessage, and content headers with HttpContent objects.
So is it possible to comply with the spec or is it one of those "hold your nose and ship" situations?