http put post請求區別
阿新 • • 發佈:2018-09-13
-s str 通過 font and 資源 api pda hat
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無法指定資源路徑。
http put post請求區別