Which browser support REST completely. Means Get,P

2020-02-10 09:33发布

问题:

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?

回答1:

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.



回答2:

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.



回答3:

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.