Is there any reason not to use HTTP PUT and DELETE in a web application?

Actually a fair amount of people use PUT and DELETE, mostly for non-browser APIs. Some examples are the Atom Publishing Protocol and the Google Data APIs:

  • http://www.ietf.org/rfc/rfc5023.txt
  • http://code.google.com/apis/gdata/docs/2.0/basics.html

Beyond that, you don’t see PUT/DELETE in common usage because most browsers don’t support PUT and DELETE through Forms. HTML5 seems to be fixing this:

  • http://www.w3.org/TR/html5/forms.html#form-submission-0

The way it works for browser applications is: people design RESTful applications with PUT and DELETE in mind, then “tunnel” those requests through POSTs from the browser. For example, see this SO question on how Ruby on Rails accomplishes this using hidden fields:

  • How can I emulate PUT/DELETE for Rails and GWT?

So, you wouldn’t be on your own designing your application with the larger set of HTTP verbs in mind.

EDIT: By the way, if you’re curious about why PUT/DELETE are missing from browser based form posts, it turns out there’s no real good technical reason. Reading around this thread on the rest-discuss mailing list, especially Roy Fielding’s comments, is interesting for some context:

  • http://tech.groups.yahoo.com/group/rest-discuss/message/9620?threaded=1&var=1&l=1&p=13

EDIT: There are some comments on whether AJAX libraries support all the methods. It does come down to the actual browser implementation of XMLHttpRequest. I thought someone might find this link handy, which tests your browser to see how compliant the HttpRequest object is with various HTTP options.

  • http://www.mnot.net/javascript/xmlhttprequest/

Unfortunately, I don’t know of a reference which collects these results.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)