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

12,812

Solution 1

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:

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:

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:

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:

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.

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

Solution 2

Quite simply, the HTML 4.01 form element only allows the values "POST" and "GET" in its method attribute

Solution 3

Some proxy servers with tough security policies might drop them. I'm using PUT and DELETE anyways.

Solution 4

I've read that some browsers do not support other HTTP methods properly, though I can't name any specifics.

Rails, in particular, will pack your forms with a method parameter to explicitly set this even if the browser doesn't support those methods. That seems like a reasonable precaution if you're going to do this.

Solution 5

I say use all the features of HTTP, browsers be damned, lol. Maybe it'll inspire more complete and proper use of the HTTP protocol moving forward. There's more happening on the net than just POSTs and GETs. About time browser implementations reflected this.

Share:
12,812
Sasha Chedygov
Author by

Sasha Chedygov

Stuff I'm great at: Frontend JavaScript (esp. React), Python, Node.js, HTML/CSS Stuff I'm good at: SQL, UX Stuff I'm learning: Rust, cloud infrastructure stuff

Updated on June 26, 2022

Comments

  • Sasha Chedygov
    Sasha Chedygov almost 2 years

    Looking around, I can't name a single web application (not web service) that uses anything besides GET and POST requests. Is there a specific reason for this? Do some browsers (or servers) not support any other types of requests? Or is this only for historical reasons? I'd like to make use of PUT and DELETE requests to make my life a little easier on the server-side, but I'm reluctant to because no one else does.