Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
774 views
in Technique[技术] by (71.8m points)

ruby on rails - Which browser support REST completely. Means Get,Post,PUT and DELETE method?

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...