HTTP POST: content-length header required?

核能气质少年 提交于 2019-11-27 22:55:35

问题


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.

The core question of all:

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.


回答1:


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 Message Length



来源:https://stackoverflow.com/questions/14758729/http-post-content-length-header-required

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!