http put post請求區別


1、RESTful API

REST: Representational State Transfer 

url 對應服務器上的一種資源,e.g. 數據,圖片等,所以url 中只含有名詞,通過HTTP動詞來描述對資源的操作方式。

HTTP 動詞

  • GET: 獲取資源
  • POST:創建或更新資源
  • PUT: 創建或更新資源
  • DELETE:刪除資源
  • HEAD:獲取請求報文頭部,不常用
  • OPTIONS:獲取信息,關於資源的哪些屬性是客戶端可以改變的, 不常用

2、put post區別

POST: > modify and update a resource POST /questions/<existing_question> HTTP/1.1

> create a resource: POST /questions HTTP/1.1

> Note that the following is an error: POST /questions/<new_question> HTTP/1.1  PUT: > To overwrite an existing resource: PUT /questions/<existing_question> HTTP/1.1

> create a resource: PUT /questions/<new_question> HTTP/1.1

在更新資源的操作上,POST 和 PUT 基本相同。

在創建資源時,PUT可以指定資源路徑,POST無法指定資源路徑。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM