http-content-length

HTTP POST: content-length header required?

五迷三道 提交于 2019-11-29 05:25:00
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. 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

Python requests remove the Content-Length header from POST

感情迁移 提交于 2019-11-29 02:30:00
I'm using the python requests module to do some testing against a site. The requests module allows you to remove certain headers by passing in a dictionary with the keys set to None. For example headers = {u'User-Agent': None} will ensure that no user agent is sent with the request. However, it seems that when I post data, requests will calculate the correct Content-Length for me even if I specify None, or an incorrect value. Eg. headers = {u'Content-Length': u'999'} headers = {u'Content-Length': None} I check the response for the headers used in the request (response.request.headers) and I

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

Python requests remove the Content-Length header from POST

女生的网名这么多〃 提交于 2019-11-27 16:51:23
问题 I'm using the python requests module to do some testing against a site. The requests module allows you to remove certain headers by passing in a dictionary with the keys set to None. For example headers = {u'User-Agent': None} will ensure that no user agent is sent with the request. However, it seems that when I post data, requests will calculate the correct Content-Length for me even if I specify None, or an incorrect value. Eg. headers = {u'Content-Length': u'999'} headers = {u'Content