Why don’t browsers implement HTTP’s PUT and DELETE protocols?

Asked

Viewed 1,181 times

7

For some reason the Internet browsers (Chrome, Firefox, IE, ...) decided to only implement the GET and POST methods of the HTTP protocol.

Other methods such as PUT and DELETE were left out.

Why?

My doubt arose because from the official Ruby on Rails guide:

The Rails framework encourages Restful design of your Applications, which Means you’ll be making a Lot of "PATCH" and "DELETE" requests (Besides "GET" and "POST"). However, Most browsers don’t support methods other than "GET" and "POST" when it comes to submitting Forms.

How translated is:

The Rails framework encourages the use of rest standard in your applications, which means you will make several requests "PATCH" and "DELETE" (in addition to "GET" and "POST"). However, most browsers do not support methods other than "GET" and "POST" when using forms.

Obs.: so apparently, these methods are only not supported via tag <form>...</form>.

2 answers

6

That is not true. All modern browsers (i.e., IE, Chrome, Firefox, Safari that have been released in the last 3 years, possibly more) support all HTTP methods. GET is supported in multiple scopes, as in all tags with an attribute src (e. g., <script src="o endereço que será acessado via GET"></script>).

To use the other methods, you usually use the object XMLHttpRequest, where you define the HTTP method you want to use via open().

There are also other ways to send HTTP requests through the browser, for example in a submit of a <form>. In this case the browsers do not support methods other than GET and POST the HTML Forms definition limits the verbs only to these two. See the specification of HTML 4 or of HTML 5 for more details.

One problem you may be encountering is that there are some settings for servers which do not support requests using PUT or DELETE - there are some versions behind the default IIS configuration was that way (you can enable the other methods by changing the configuration). But that would be a problem of the server, not the browser.

  • I updated my question.

  • I updated the answer :)

2


That answer is another huge comment to the answer from @carlosfigueira, but that contains some information until interesting.


As for the statement that modern browsers implement others HTTP Verbs, I don’t have my doubts. This is because a year ago I and some forum colleagues tested and at least Chrome, Opera and Safari, updated so far, respected only the POST. The others (PUT, DELETE, OPTIONS...) they assumed the GET method.

That is, so you can enjoy these other verbs in the application server-side, you have two alternatives, one of them a small gambiarra because it violates the RFC 2616:

  1. Use XHR. Pro: You can use any verb you need. Against: Obstructive! If your Application depends on JS and it is not available, it does not work.
  2. Pass the verb directly to the URL or some field Hidden.

    For example, to delete a user without full DELETE support, we would have:

    http://www.domain.com/management/user/delete/1

  • Ruby on Rails, for methods that should be DELETE or PUT, creates POST forms but with an attribute Hidden called "_method" worthwhile "DELETE" or "PUT", that are evaluated in the Rails route layer to decide which is the correct controller/action to trigger.

  • That is, it does more that work for programmers :p

  • 1

    Thank you very much for the downside, whoever you are.

  • But the carlosfigueira answer clearly says that PUT and DELETE do not work in Forms. This is defined in the HTML specification. The 4 methods, only in XHR.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.