HTTP POST:需要内容长度标头? [英] HTTP POST: content-length header required?

查看:403
本文介绍了HTTP POST:需要内容长度标头?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在尝试优化多个应用程序之间基于http的数据传输。
我们当前的方法,首先下载然后创建后请求,显然会增加额外的IO /内存负载和延迟,我想绕过它。

I'm currently trying to optimize http-based data transfer between several applications. Our current approach, downloading first and then creating the post-request, obviously add extra IO/memory load and latencies, which I'd like to circumvent.

所有的核心问题:

是否需要在HTTP POST请求中发送Content-Length标头?
IIRC,HTTP 2616声明它是可选的,但我不确定应用程序在这一点上的实际行为。

Is it required to send a "Content-Length" header in HTTP POST requests? IIRC, HTTP 2616 declares that it's optional, but I'm not sure how applications actually behave at this point.

推荐答案

取决于你选择的意思。如果你的意思是你可以随时省略标题,那么它就不是可选的。 HTTP规范在使用该标头时具有非常具体的规则。如果您不知道长度,可以使用不同的方式发送数据。例如,分块编码。

Depends what you mean by optional. If you mean that you can just omit the header anytime you like then no, it is not optional. The HTTP spec has very specific rules when to use that header. There are different ways of sending the data if you don't know the length. Chunked encoding for example.

4.4消息长度

这篇关于HTTP POST:需要内容长度标头?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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