What's the purpose of HTTP PUT?

This question already has an answer here:

  • PUT vs. POST in REST 32 answers

  • For RESTful APIs POST has a specific meaning (create a resource) while PUT has a different one (update an existing resource):

  • GET retrieves a list or an item
  • PUT replaces a collection or an item
  • POST creates a new item in a collection
  • DELETE deletes a collection or an item
  • However, if there's really "script.php" whoever developed it was not very thorough when creating his API. "script.php" is pretty much not RESTful at all... Usually the URL structure of a proper RESTful API looks eg like this:

  • http://example.com/questions would be a collection (GET to list, PUT to replace all items, POST to create a new item, DELETE to delete all items)
  • http://example.com/questions/123 would be an item (GET to retrieve, PUT to replace, POST usually unused, DELETE to delete that item)
  • 链接地址: http://www.djcxy.com/p/7012.html

    上一篇: servlet http post和put方法之间的区别?

    下一篇: HTTP PUT的目的是什么?