[英]Can HTTP PUT request have application/x-www-form-urlencoded as the Content-Type?
Is it valid to send form data in an HTTP PUT request?在 HTTP PUT 请求中发送表单数据是否有效? If you could point me to a spec then that would be great.如果您能指出我的规格,那就太好了。
I have gone through the HTTP 1.1 spec.我已经通过了 HTTP 1.1 规范。 But I did not find whether PUT requests can have form data or not.但我没有发现 PUT 请求是否可以有表单数据。
I am using Java for creating and accessing RESTful webservices.我正在使用 Java 来创建和访问 RESTful Web 服务。 POST supports application/x-www-form-urlencoded
as the Content-Type. POST 支持application/x-www-form-urlencoded
作为 Content-Type。
From the specification, I understand that POST is for creating a new resource (a subresource to the resource identified by the request URI) and PUT is for create or update a resource.从规范中,我了解到 POST 用于创建新资源(请求 URI 标识的资源的子资源),而 PUT 用于创建或更新资源。
But my doubt is whether PUT method also can have form data in it?但我的疑问是 PUT 方法是否也可以包含表单数据? I trying to find out whether it is fine according to the spec.我试图根据规范找出是否可以。 And I can't find anything about this in the HTTP 1.1 spec.我在 HTTP 1.1 规范中找不到任何关于此的内容。
Yes you can use application/x-www-form-urlencoded with PUT.是的,您可以将 application/x-www-form-urlencoded 与 PUT 一起使用。 The HTTP spec does not limit what methods can be used with what media types. HTTP 规范不限制什么方法可以用于什么媒体类型。
The currently in-progress Httpbis spec has a significantly expanded discussion of PUT http://tools.ietf.org/html/draft-ietf-httpbis-p2-semantics-14#page-18目前正在进行的 Httpbis 规范对 PUT http://tools.ietf.org/html/draft-ietf-httpbis-p2-semantics-14#page-18进行了显着扩展的讨论
Since the PUT method is used to store the enclosed entity under the supplied URI and the Content-Type header field is an entity header field , it is legitimate to use a Content-Type header field in a PUT request.由于PUT 方法用于在提供的 URI 下存储封闭的实体,并且Content-Type header 字段是实体 header 字段,因此在 PUFT 请求中使用Content-Type Z099FB995346F33C749F6E40E3Z 字段是合法的。
Now the remaining question is whether the receiving server can handle such request and Content-Type information appropriately.现在剩下的问题是接收服务器是否可以适当地处理此类请求和Content-Type信息。 In worst case it can't handle the Content-Type header field and returns a 501 response:在最坏的情况下,它无法处理Content-Type header 字段并返回 501 响应:
The recipient of the entity MUST NOT ignore any Content-* (eg Content-Range ) headers that it does not understand or implement and MUST return a 501 (Not Implemented) response in such cases.实体的接收者不能忽略任何它不理解或不实现的Content-* (例如Content-Range )标头,并且在这种情况下必须返回 501(未实现)响应。
Here is the HTTP spec from the wc3这是 wc3 中的 HTTP 规范
http://www.w3.org/Protocols/rfc2616/rfc2616.html http://www.w3.org/Protocols/rfc2616/rfc2616.html
Additionally, here are the pages for Content-Type此外,这里是 Content-Type 的页面
http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.17 http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.17
and PUT和放
http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.6 http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.6
If there is a specific language you want help with in regard to your HTTP PUT, please update your question with the specifics如果您需要有关 HTTP PUT 的特定语言的帮助,请使用具体信息更新您的问题
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.