TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

PUT or POST: The REST of the Story

57 点作者 chwolfe将近 15 年前

6 条评论

angelbob将近 15 年前
Quick summary: PUT is idempotent, and should be used when you're sending the full text or properties of an item, or otherwise doing some where doing it a second time is harmless. POST is not, and should be used for requests like "increment this field" or "add a new sub-item to this parent item" where doing it twice will give a very different result than doing it once.
评论 #1443332 未加载
评论 #1443791 未加载
评论 #1443306 未加载
ramen将近 15 年前
The idempotency of PUT is supposedly useful with caching web proxies, but I don't know of any caching web proxies that support PUT. Are there any?
评论 #1443503 未加载
评论 #1443801 未加载
malkia将近 15 年前
One reason I read HN, is to learn how to come up with good titles :)
piotrSikora将近 15 年前
I can't agree with last few paragraphs. "Location" header should be used for redirections. There is "Content-Location" header which should be used to identify real location of the content.<p>So, for example, for newly created objects ("POST /objects/"), you should return content with header "Content-Location: <a href="http://website.com/objects/object_id" rel="nofollow">http://website.com/objects/object_id</a> ".
评论 #1443483 未加载
keefe将近 15 年前
it's worth remembering that firefox won't let you PUT an attachment from a form, it must be POST which is a real pain for dealing with couchdb sometimes
评论 #1444005 未加载
terra_t将近 15 年前
I ~love~ REST!<p>People who don't know anything about building distributed systems hop on the REST bandwagon and before you know it they've got a monstrosity that doesn't work.<p>I come in as a $150 an hour consultant, explain really clearly that it's ~very~ hard to get business rules and transactions working right in a REST situation, re-architect the system with POX RPC and get it working.<p>When I see blog entries about the "finer points of REST" I hear ka-ching, ka-ching, ka-ching!
评论 #1443789 未加载
评论 #1446947 未加载