如何发出HTTP PUT请求? [英] How is a HTTP PUT request typically issued?

查看:190
本文介绍了如何发出HTTP PUT请求?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道HTTP PUT是一个幂等请求,根据定义(引自 rfc

I know HTTP PUT is an idempotent request that store something at a specific URI, according to the definition (quoted from the rfc)

The PUT method requests that the enclosed entity be stored under the supplied Request-URI.

但是'封闭实体'的定义是什么?我似乎无法发送表单数据(如HTTP POST请求)。如何通过JSON / XML或其他序列化格式发送实体的表示?

But what is the definition of 'enclosed entity'? It doesn't seem possible for me to send form data (like for HTTP POST request) over. What about sending representation of the entity via JSON/XML or in other serialization formats?

简而言之,如何将HTTP PUT请求发送到存储/更新信息然后是一个特定的URI?

In short, how does one send a HTTP PUT request over to store/update info at a specific URI then?

推荐答案

包含的实体是HTTP消息体中包含的有效负载数据(在任何传输编码之后)如果您在发送邮件正文时遇到问题,那么您可能忘记包含Content-Length标头 - 这是表明HTTP邮件有正文的两种方法之一。

The enclosed entity is the payload data contained in the HTTP message body (after any transfer encodings have been removed.) If you're having trouble sending the message body then it could be that you've forgotten to include a Content-Length header - that's one of two ways to indicate that the HTTP message has a body.

除了这种语义差异外,PUT与POST相同:使用POST,URI标识将处理实体的资源,例如servlet。使用PUT,URI标识实体本身,例如将使用实体主体的内容创建/替换的文件。

PUT is the same as POST except for this semantic difference: With POST the URI identifies a resource that will handle the entity, such as a servlet. With PUT the URI identifies the entity itself, for example a file that will be created/replaced with the contents of the entity body.

这篇关于如何发出HTTP PUT请求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆