Skip to content
perigrin edited this page Mar 5, 2012 · 2 revisions

HTTP States

So someone came to us recently and pointed to Webmachine. Webmachine is conceptually very similar to Magpie, but Magpie is as far as we can tell more generic in it's implementation and it's approach. However webmachine has a nice little graphic of the Finite State Machine that they implement. Here's the breakdown on how these line up to Magpie.

503 Unavailable

This probably should be handled (for maintenance downtimes) via the plack layer with HTTP::Throwable. If you need to deal with it programmatically you can use Magpie::Transformer::ServiceUnavailable.

As for hooks into the pipeline, this could be done at many stages and is application specific. We leave it up to you where you add in this feature.

501 Not Implemented (Unsupported HTTP Method)

The HTTP 1.1 spec says that this is defined for "all known resources" on the server. However Magpie neither operates on the Server level, nor knows (or cares to know) at a global level what every resource implements.

Currently Magpie is returning 501 Not Implemented errors for unimplemented resources on a per-resource level. We're trying to figure out how to properly handle those cases and will adjust accordingly.

414 Request URI Too Long

Mapgie has no intrinsic limits on Request URIs that Plack doesn't have. This definitely should be handled at the Plack/PSGI Server level.

405 Method Not Allowed

Magpie Resources (via the resource Base class) will deny any non HTTP 1.1 method as "Not Allowed". (currently this is in a branch)

400 Request Malformed

This should again be handled at the Plack/PSGI server level. Magpie relies on the Plack environment being properly setup. However if we get something that Plack::Request->new() can't parse we will throw a 400.

401 Unauthorized

Authorization can definitely be handled at the Plack level, or by Plack middleware. There is middleware for Basic and Digest Auth as well as more advanced authentication frameworks on CPAN. These can be natively as pipeline components via the configuration.

403 Forbidden

This should be handled by the Auth component.

501 Not Implemented (Unknown or unsupported Content- header)

Support for this is being looked at. It would be handled at theContent-Negotiation stage in Magpie::Match.

415 Unknown Media Type

Support for this is being looked at. It would be handled at the Content-Negotiation stage in Magpie::Match.

413 Request Entity Too Large

Like URI length, Magpie has no inherent size restrictions here.

200 OK (Options)

Magpie handles all HTTP methods identically (that it is processes them through to the Resource stage of the pipeline). This is handled by the Resource stage explicitly where the default is a 200 OK.

This means any pipeline stages *before the Resource that explicitly register interest in a OPTIONS method will have a chance to weigh in.

406 Not Acceptable

Support for this is being looked at. It would be handled at the Content-Negotiation stage in Magpie::Match.

412 Precondition Failed (If-Match)

Support for this is being looked at. It would be handled at the Resource level in Magpie.

412 Precondition Failed (If-None-Match and If-Modified-Since)

This can be easily handled by Plack::Middleware::ConditionalGET and Plack::Middleware::ETag. These components may be added automatically in the future.

301 Moved Permanently

This is handled by the Resource class either via the PUT method, or via a possible resource role that wraps the other HTTP methods method.

404 Not Found

Is handled explicitly by the Resource class.