http - 201 的响应实体类型已创建?

标签 http formatting httpresponse content-type language-lawyer

RFC 2616

10.2.2 201 Created

The response SHOULD include an entity containing a list of resource characteristics and location(s) from which the user or user agent can choose the one most appropriate. The entity format is specified by the media type given in the Content-Type header field.

如果我请求创建 image/png

POST /my/images HTTP/1.1
Content-Type: image/png
...

响应的实体是否应该是格式为 PNG 的“资源特征和位置列表”?

将特征和位置列表格式化为 PNG 似乎非常错误。我正确地阅读了 HTTP 标准吗?

最佳答案

a) 您正在阅读错误的文档。相关的是 RFC 7231。

b) 来自http://greenbytes.de/tech/webdav/rfc7231.html#status.201 :

“6.3.2 201已创建

201(已创建)状态代码表示请求已得到满足,并导致创建一个或多个新资源。请求创建的主要资源由响应中的 Location header 字段标识,或者如果未收到 Location 字段,则由有效请求 URI 标识。

201 响应负载通常描述并链接到所创建的资源。请参阅第 7.2 节,了解 201 响应中验证器 header 字段(例如 ETag 和 Last-Modified)的含义和用途的讨论。”

因此删除了Content-Type的特别提及;它在所有 HTTP 消息中具有相同的含义。

关于http - 201 的响应实体类型已创建?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27390496/

相关文章:

java - Apache HttpClient - 需要使用 MultiThreadedHttpConnectionManager?

http - 带有 ARR : Route soap message to different server depending of the soap content 的 IIS

c++ - clang-format 堆栈所有 if 语句参数(如果它们太长)

c - 如何格式化代码以便触发 while 循环 C

java - 从响应实体 json 获取一个字段

ios - iOS 应用程序提交中的导出合规性

c++ - 简单的 HTTP 服务器库

java - 如何通过格式化将 double 舍入为两位小数,然后使用该数字?

java - 响应 sendRedirect() 处理

javascript - jQuery .load() html 页面,里面有 javascript