WhatfettleSo which CRUD Operation is HTTP POST?

Spaceglenda37 - The Plan9 project mascot

As Stefan Tilkov says, many people still like to think of REST in terms of CRUD. So here’s my 2p worth:

All the above work on a complete copy of the thing identified by a URI. PUT sends a new copy of the thing likely to be returned by the next ‘GET’ meaning caching could potentially be made to work both ways. Well, if you’re very optimistic or offline. Using HEAD and ETag is going to help here.

Then there are to mostly forgotten OPTIONS which has some potential, TRACE, CONNECT and of course you can foist your own made up HTTP verbs onto the world if you’re big, evil or someone like Microsoft (not mutually exclusive :).

So what about POST? Isn’t that just UPDATE? Well POST sends “a new subordinate”, i.e. not necessarily the whole thing. The difference is the message sent can be anything, and the agent can do anything with that message, including READ, CREATE, DELETE. Unfortunately a happy POST mostly results in 200 OK which is HTTP speak for Stuff Happens.

This means that POST requests aren’t something on the web (a rather meaningless term), but a hack to enable HTML Forms to buy a book or send a text message or any one of the fantastic things which make the Web useful. It also enables HTTP to be used to tunnel arbitrary SOAP, POX, JSON, whatever, messages, which often don’t map onto anything CRUD like at all, like ChangeLightBulb or FireNuclearMissiles.

An idea that’s been around forever is mapping the Unix architecture of Everything is a File onto the Web’s Everything is a URI making GET a ‘<‘, PUT a ‘>‘ and POST a pipe ‘|‘. Maybe Plan 9 has finally come of age.

But, wait, there’s a big buzzing fly in the room: content negotiation. The power of HTTP means the same thing identified by a URI to be exchanged using different representations. That’s useful when you’d like today’s weather as text, sound or video, but does rather mess up such simple analogies.