clarify PUT failure response status (400, 404 or 405) when resource handler doesn't exists

Hello httpbis,

The following sentence in RFC 2616 is not detailed enough to understand fully:

RFC 2616 Section 9.6 - PUT
…"If the resource could not be created or modified with the Request-URI, an appropriate
   error response SHOULD be given that reflects the nature of the problem."…

De-facto many HTTP servers are responding with the status code 404 Not Found when applying PUT to a resource which doesn't have a "handling controller / cannot be routed internally".
"handling controller" is implementation detail and means: a GET request to that resource is 404.

The nature of PUT is to create a resource if it doesn't exists!
→ 404 Not Found can never be an accurate status code (because of course the resouce doesn't exists, it should be created)

I guess the proper response status code would be 405 Method Not allowed?
→ but this is also strange because it implies that there is already a resource?

Otherwise I would use 400 Bad Request but this is to generic and not understandable by a client.

Or maybe is 404 really correct? It can mean: "There is no resource" or also "There is no representation of the resource".

In my opinion this should be clarified in the RFC.

Received on Monday, 10 February 2014 20:20:50 UTC