4

Which browser support REST completely? Means Get,Post,PUT and DELETE method?

I understood the rails way to understand PUT and DELETE is "_method" hidden variable like

  <form id="form_id" action="" method="PUT" >
   -- form content --
   </form>

method="PUT"?

Or am I thinking wrong?

Manish Shrivastava
  • 30,617
  • 13
  • 97
  • 101
  • Basically web browsers can only use GET/POST in form and Rails deals with that by tunneling PUT/DELETE method in a POST request. (See Vinnie answer). Check this out to create a correct form: http://guides.rubyonrails.org/form_helpers.html – basgys Jan 09 '12 at 21:32

3 Answers3

9

In many REST frameworks calling the HTTP PUT or DELETE operations from a browser can be achieved through what is known as an "Overloaded POST". What this means is you submit the request from the browser to the server as a POST request with some information appended to the URL specifying the actual HTTP method that should be used.

I know that the Restlet framework for Java follows this approach and I believe Rails does as well.

So if you have a REST API defineed like this:

  • POST - http://myservice/myobject -> creates a new object and returns the object id
  • GET - http://myservice/myobject/id -> returns the object
  • PUT - http://myservice/myobject/id -> updates the object
  • DELETE - http://myservice/myobject/id -> deletes the object

using Overloaded POST from the browser you could also

  • POST - http://myservice/myobject/id?method=PUT -> updates the object
  • POST - http://myservice/myobject/id?method=DELETE -> deletes the object

In fact, for Flex which does not support PUT or DELETE, this is the only way to call these REST operations.

Vinnie
  • 12,400
  • 15
  • 59
  • 80
  • @Vinnie Since Rails & Restlet are just turning PUT and DELETE requests into POST requests with a magic field to tell the server what to do with the request, how is that any more RESTful than a web app that always used POST requests with a magic field to tell the server what to do? Isn't the latter architecture the major thing that REST is meant to get away from? – Jazz Jul 27 '12 at 18:17
  • It is preferable to use native PUT or DELETE - when you can. Where overloaded POST comes into play is when you want to call the PUT or DELETE operations from technology that doesn't support these HTTP operations. Flex is one such technology - it only supports GET and POST. Some browsers have the same limitations. These are the exceptions where overloaded POST would be used instead of the "correct" REST API operations. – Vinnie Jul 29 '12 at 15:55
  • According to this post: http://programmers.stackexchange.com/questions/114156/why-there-are-no-put-and-delete-methods-in-html-forms PUT and DELETE are not included in forms in the HTML5, XHTML1 and HTML4 standards – Ross Attrill May 21 '14 at 00:49
1

This question is almost the same as this one: Are the PUT, DELETE, HEAD, etc methods available in most web browsers?, see there for a great answer.

Also, "GET, POST, PUT and DELETE" is not "REST". All four are different methods in the HTTP specification, REST is an architectural style that uses those four.

Community
  • 1
  • 1
Tom De Leu
  • 8,144
  • 4
  • 31
  • 30
-4

PUT and DELETE are just specifications, and are not implemented by any browser and web server.

So donot design RESTful web service with support for PUT or DELETE if you are sending request.

Acn
  • 1,010
  • 2
  • 11
  • 22
  • 1
    "do not design RESTful web service with support for PUT or DELETE" is not a responsible design choice and should not be an option for anyone developing a RESTful API. These HTTP methods (PUT & DELETE) are integral to how a RESTful web service should be defined so others can figure out how to use your services. http://en.wikipedia.org/wiki/Representational_state_transfer#RESTful_web_services – Vinnie Jan 09 '12 at 15:29