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
6
votes
2 answers

Why does Content-Length HTTP header field use a value other than the one given in Java code?

I have a piece of Java code to transfer a byte array to HTTP server: HttpURLConnection connection = (HttpURLConnection)…
chance
  • 6,307
  • 13
  • 46
  • 70
6
votes
3 answers

If a HTTP/1.0 client requests Connection: keep-alive, will it understand chunked encoding?

If my HTTP server gets an HTTP/1.0 request with the "Connection: keep-alive" header, is it a fair bet that the client will understand "Transfer-Encoding: chunked"? Essentially, I'm trying to decide whether to honour the "Connection: keep-alive"…
5
votes
1 answer

HTTP Content-Length and Chunked Transfer-Encoding. Is there a 2GB Limit?

Is a HTTP Content-Length over 2GB or 4GB supported by modern webservers? How about the chunks in HTTP Chunked Transfer Encoding? Can an individual HTTP chunk exceed 2GB in length? I need to know to use 32-bit integers or 64-bit integers in my code.
unixman83
  • 9,421
  • 10
  • 68
  • 102
5
votes
0 answers

ASP.NET core: HTTP HEAD requests and Content-Length header

This question is related to an ASP.NET core 2.2 web application (targeting .NET core) exposing some web api controllers implemented used the mvc middleware. All the action methods available in all the controllers must respond to both the GET and the…
5
votes
1 answer

What are the benefits of specifying a Content-Length header in HTTP/1.0 responses?

The HTTP/1.0 specs state that the server can indicate the length of a response containing an entity body by sending a Content-Length header, or closing the connection when the entire response has been sent. So the Content-Length header, for normal…
Paolo
  • 15,233
  • 27
  • 70
  • 91
5
votes
1 answer

Android: URLConnection.getContentLength() giving incorrect value

I'm trying to get the size of the contents of a URL using: URLConnection conn = null; URL url = null; url = new URL("https://dl.dropboxusercontent.com/u/90210205/Default.html"); conn = url.openConnection(); conn.connect(); InputStream in = new…
Eduardo
  • 6,900
  • 17
  • 77
  • 121
5
votes
1 answer

textarea occasionally missing in $_POST but content_length always correct?

A strange bug has popped up on a server running a fairly active site. Server: Apache/2.2.3 (CentOS) PHP: 5.2.6 eAccelerator 0.9.5.3 While using multipart forms, occasionally data sent from a textarea will be missing in the $_POST We know the…
ck_
  • 3,353
  • 5
  • 31
  • 33
4
votes
1 answer

Cloudflare Content Type

I have just started to use CloudFlare and have run into an issue with it's CDN service. I want my script to send back a the Content-Type header. I have tried to use page rules but doesn't help one bit. I just want to get the content length! PHP…
user3732111
  • 151
  • 1
  • 2
  • 8
4
votes
2 answers

Content-length header not being set correctly

I have a php script (actually https://drupal.org/project/file_force) that is forcing users who click on a link to download that link by adding the correct headers to the response. This link works fine 90% of the time. Occasionally the incorrect…
Nicholas Evans
  • 2,194
  • 2
  • 16
  • 18
4
votes
1 answer

How this GET response Content-Length calculate?

The Response headers is: HTTP/1.1 200 OK Cache-Control: private Content-Type: text/html; charset=utf-8 Content-Encoding: gzip Vary: Accept-Encoding Server: Microsoft-IIS/8.0 X-AspNetMvc-Version: 4.0 X-AspNet-Version: 4.0.30319 X-SourceFiles:…
artwl
  • 3,502
  • 6
  • 38
  • 53
3
votes
2 answers

why does golang http ResponseWriter auto add content-length if it's no more than 2kb

func (handler Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { var content string ... w.Write([]byte(content)) } if len(content) <= 2048, the content-length will be added automatically in the response. And if it's over 2048,…
zealllot
  • 33
  • 5
3
votes
1 answer

Content-Length header is not getting set for PATCH requests with empty/nil payload - GoLang

I observed that Content-Length header is not getting set for PATCH requests with empty/nil payload. Even if we manually set it by req.Header.Set("content-length", "0") it is not actually getting set in the out going request. This strange behaviour…
tharinduwijewardane
  • 2,593
  • 2
  • 16
  • 28
3
votes
1 answer

How to compute content length of multipart file request with formdata in go

Currently trying to create a multipart upload request to upload a png along with some extra body params. The server is returning the response: The request body did not contain the specified number of bytes. Got 142,827, expected 146,836 So…
3
votes
0 answers

Gunicorn gives ERR_CONTENT_LENGTH_MISMATCH when running without Nginx

I'm hosting a Flask built website with Gunicorn and Nginx through Supervisor, which works perfectly well. In my supervisord.conf file I run gunicorn as follows: command=/home/beta/imd/venv/bin/gunicorn --worker-class eventlet -b 127.0.0.1:5000 -w 1…
kramer65
  • 50,427
  • 120
  • 308
  • 488
3
votes
1 answer

POST request with large body received empty on server side

When issuing a POST request with a large body to my Play framework action method, I get null when extracting the data. If the body is fairly small, I can retrieve the data just fine. Here's a sample short data set: { "creator": "zoltan", …
Zoltán
  • 21,321
  • 14
  • 93
  • 134