405 Method Not Allowed

1,504 views
Skip to first unread message

M. Herold

unread,
Apr 25, 2012, 9:15:28 PM4/25/12
to servic...@googlegroups.com
If say, a resource need not support PUT requests as it will never be updated, I may choose to simply not implement PUT. My expectation then is that people attempting to perform a PUT request on this resource is that they receive a 405 HTTP status code in response, and that's precisely what happens. Unfortunately, I don't believe ServiceStack is fully following the HTTP specification as the Allow headers are absent.

The specification:

10.4.6 405 Method Not Allowed
The method specified in the Request-Line is not allowed for the resource identified by the Request-URI. The response MUST include an Allow header containing a list of valid methods for the requested resource.

When I perform a PUT on my resource which only includes GET and POST as options, I see this:

Status Code: 405
Date: Thu, 26 Apr 2012 01:06:50 GMT
X-AspNet-Version: 4.0.30319
X-Powered-By: ServiceStack/3.69 Win32NT/.NET
Connection: Close
Content-Length: 0
Server: ASP.NET Development Server/10.0.0.0
Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS
Access-Control-Allow-Origin: *
Cache-Control: private

There is no Allow header, which I believe is distinct from Access-Control-Allow-Methods as that's for cross-domain nonsense. 

I could probably work around this, but it felt more like SS just missed a step.

Thanks as always
Michael

Demis Bellot

unread,
Apr 25, 2012, 9:32:35 PM4/25/12
to servic...@googlegroups.com
You can specify any HTTP headers you wish, either globally or on a per service basis, as the CORS example demonstrates:

Feel free to put as many headers as you wish, I personally don't like polluting the response headers un-necessarily, unless I have to.

Cheers,

M. Herold

unread,
Apr 26, 2012, 2:43:51 PM4/26/12
to servic...@googlegroups.com
Works for me! Thanks Demis. 
Reply all
Reply to author
Forward
0 new messages