Questions tagged [http-content-length]

The Content-Length header specifies the length (in bytes) of the content, both for requests and responses.

The Content-Length header specifies the length (in bytes) of the content, both for requests and responses. It is especially important when using persistent connections, so the end of one message and the start of the next can be delineated. It is not used for chunked content.

118 questions
43
votes
1 answer

HTTP POST: content-length header required?

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…
37
votes
4 answers

content-length when using http compression

The client is making a range request 0-1023 to the http server. It prefers gzip compression with Accept-Encoding: gzip;q=1.0, identity; q=0.5, *;q=0 in the request. What would be the content-length in the response header? Will it be 1024 or the…
derekwei
  • 473
  • 1
  • 6
  • 10
21
votes
4 answers

How is an HTTP multipart "Content-length" header value calculated?

I've read conflicting and somewhat ambiguous replies to the question "How is a multipart HTTP request content length calculated?". Specifically I wonder: What is the precise content range for which the "Content-length" header is calculated? Are…
Moshe Rubin
  • 1,944
  • 1
  • 17
  • 37
16
votes
1 answer

HTTP Content-Length and Content-Encoding

Does the HTTP response header Content-Length pertain to the length before or after decoding the body due to Content-Encoding: gzip?
Matt Joiner
  • 112,946
  • 110
  • 377
  • 526
14
votes
2 answers

How to POST with multipart/form-data header and FormData using fetch

This is a CURL example which works fine: curl -X POST \ \ -H 'authorization: Bearer ' \ -H 'content-type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW' \ -F file=@algorithm.jpg \ -F userId= I'm…
rfc1484
  • 9,441
  • 16
  • 72
  • 123
13
votes
3 answers

How do I disable 'Transfer-Encoding: chunked' encoding in Varnish?

Using Varnish 4, I have a set of backends that're responding with a valid Content-Length header and no Transfer-Encoding header. On the first hit from a client, rather than responding to the client with those headers, Varnish is dropping the…
11
votes
1 answer

Leveraging etags and chunked encoding at the same time?

updated question How can my application leverage etags, and does introducing streaming/chunked encoding introduce any complications? original question When doing HTTP streaming with Transfer-Encoding: chunked, Content-Length can't be sent because…
John Bachir
  • 22,495
  • 29
  • 154
  • 227
10
votes
1 answer

Python requests remove the Content-Length header from POST

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…
joeButler
  • 1,643
  • 1
  • 20
  • 41
10
votes
6 answers

PHP Content-Length header not working

I am trying to use this code to download a .zip file
Nicolas Gnyra
  • 195
  • 2
  • 4
  • 12
10
votes
3 answers

Should newline be included in http response content length?

When sending a HTTP Response, should I conclude the response body (the content itself) with a newline (line separator)? And if so, should I include the size of the line separator (I guess increase the count with 2 if sending \r\n) in the…
runaros
  • 1,821
  • 4
  • 20
  • 25
9
votes
1 answer

Are HTTP keep-alive connections possible without content-length headers?

I understand that in HTTP 1.0, the content of a response is terminated by closing the connection. In HTTP 1.1, keep-alive connections were introduced, enabling multiple requests and responses in a single TCP connection. When multiple messages are…
Lukas Boersma
  • 1,022
  • 8
  • 26
9
votes
5 answers

Always send Content-Length in Apache?

I'm loading a particularly large JSON string that is dynamically generated by PHP. To provide some feedback to the user, I want to show download progress. I have the code figured out, and it works fine for static content such as images, JS files,…
Niet the Dark Absol
  • 320,036
  • 81
  • 464
  • 592
8
votes
1 answer

ASP.NET Web Api - the framework is not converting JSON to object when using Chunked Transfer Encoding

I have an http client in Android sending HTTP PUT requests to a REST api implemented with C# and ASP.NET WebApi framework. The framework should be able to magically convert (deserialize) the JSON into a model class (plain object) as long as the JSON…
diegosasw
  • 13,734
  • 16
  • 95
  • 159
7
votes
5 answers

Okhttp check file size without dowloading the file

The common examples for okhttp cover the scenarios of get and post. But I need to get the file size of a file with a url. Since I need to inform the the user, and only after getting their approval to download the file. Currently I am using this…
pt123
  • 2,146
  • 1
  • 32
  • 57
7
votes
1 answer

Does a HTTP resource that accepts range requests always specify content-length?

Before starting a Range request, I first check if it is supported using a HEAD request. Normally I get back something like this: curl -X HEAD -i http://bits.wikimedia.org/images/wikimedia-button.png HTTP/1.1 200 OK ... Content-Length:…
chowey
  • 9,138
  • 6
  • 54
  • 84
1
2 3 4 5 6 7 8