Making it easy to do the right thing

You'd think that a language with only a handful of verbs, only two of which are widely spoken, would be easy to learn. Not so in the case of the Hypertext Transfer Protocol, though. After more than a decade we're still sorting out how and why to use its most common verbs: GET and POST.

This perennial issue recently flared up again when Microsoft's Dare Obasanjo noted that three popular services had got it wrong. Bloglines, Flickr, and del.icio.us all offer APIs that claim to be RESTful -- that is, to conform to the Representational State Transfer principles of HTTP -- yet each violates those principles by allowing GET in some cases where only POST should be allowed. [Full story at InfoWorld.com]

For this column I tried converting a resource-altering GET request into a POST using four HTTP clients: curl, Python, Perl, and JavaScript. It's almost effortless in the first two cases, not so in the last two. I found myself wishing that Perl's LWP::Simple and JavaScript's location.href had a data option like curl and Python's urllib.urlopen do.

Here's the JavaScript example that raised the question for me. My first Greasemonkey script added a private checkbox to the del.icio.us posting form, then rewrote the page, adding a script to process the form. That script was able to use location.href to update del.icio.us, but not to update a private instance of scuttle, which (correctly) refused to allow an HTTP GET.

If JavaScript is going to be an appropriate technology of intermediation, would it make sense for it to offer an easy way to issue a non-interactive HTTP POST?


Former URL: http://weblog.infoworld.com/udell/2005/04/21.html#a1220