Questions tagged [content-length]

Entity-header field indicates the size of the entity-body.

The Content-Length entity-header field indicates the size of the entity-body, in decimal number of OCTETs, sent to the recipient or, in the case of the HEAD method, the size of the entity-body that would have been sent had the request been a GET.

374 questions
4
votes
1 answer

How can I send an incorrect Content-Length header for an HTTP request using Perl?

I'm trying to debug a weird warning that is showing up in server logs when a Plack::Request is being parsed. In some cases, a broken UserAgent will send a Content-Length header that looks something like "6375, 6375", which is obviously wrong. To…
oalders
  • 5,239
  • 2
  • 23
  • 34
4
votes
1 answer

how to add appropriate content-length header with okhttp?

I'm using okhttp to send requests to my server. The problem is that the requests okhttp sends are missing the content-length header - I can set the header manually with: Request.builder .... .addHeader("content-length","some-value") but I can't get…
Jon
  • 7,941
  • 9
  • 53
  • 105
4
votes
3 answers

How to determine the Content-Length of a gzipped file in Python?

I've a big compressed file and I want to know the size of the content without uncompress it. I've tried this: import gzip import os with gzip.open(data_file) as f: f.seek(0, os.SEEK_END) size = f.tell() but I get this…
Jprog
  • 79
  • 1
  • 8
4
votes
3 answers

Http/Smtp MIME multipart. Why boundary?

I have a question regarding the design of these protocols. Why do we use boundary to separate parts of the multipart message instead of introducing a content-length for each part? Using length the parsing would easier. Do I miss some principal…
Michael
  • 357
  • 2
  • 12
4
votes
1 answer

HttpPost + setEntity : how to know content-length?

I've set almost all my data : String capcha = editText.getText().toString(); HttpClient httpclient = new DefaultHttpClient(); HttpPost httppost = new HttpPost("myurl.asp"); // Add your data String str =…
Rob
  • 15,732
  • 22
  • 69
  • 107
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
0 answers

how to create a unique sequence of letter and numbers in constructor

I have a field call details which holds different sequence of letter and numbers, what i am trying to do is a Constructor that have a unique sequence of letter and numbers of length 8.
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
0 answers

Firefox blocking access to Content-Length Response Header

I have a simple fetch call to an audio file on S3, and am using the Content-Length header to generate a loading progress bar. On Chrome and Safari, this is totally functional, but Firefox is returning null for…
Ryan McHenry
  • 49
  • 1
  • 1
  • 5
3
votes
4 answers

File.length() returns 0

I'm trying to get the length (in bytes) of some files. The problem is that I get a zero for their length while they are not of length zero (I checked!) Moreover, every other file's method I'm using on these files works just fine. so it's just the…
Hadar
  • 39
  • 3
3
votes
1 answer

File size will not display on PHP download script during file download

I am using a PHP script to download a file when you go to a page, but I can't set it up so that when a person downloads the file, it will show the file size (mine shows "unknown time remaining"). I've looked around on Google and can't find out how…
Kevin
  • 31
  • 2
3
votes
0 answers

Servlet ignores Content-Length and uses Transfer-Encoding: chunked based on User-Agent

I want to compress response body in javax.servlet.Filter. Here is my code byte[] bytes = // compressing response body response.addHeader("Content-Encoding", "gzip"); response.addHeader("Content-Length",…
3
votes
1 answer

How to determine content-data length from chunked encoding if HTTP header not sent

How to determine the content-data length if the header is not sent and instead you receive Transfer-Encoding: chunked header?
Mohamad Elmasri
  • 461
  • 2
  • 5
  • 12
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…