Questions tagged [content-encoding]

Use this tag for questions regarding specifying content encoding on HTTP requests.

A concept in HTTP/1.1 content negotiation to indicate encryption or compression of an HTTP response (such as gzip support).

The following headers are typically used to determine the content encoding of a response. However, servers are free to use other aspects they choose.

  • Accept
  • Accept-Charset
  • Accept-Encoding
  • Accept-Language
  • User-Agent

Typical values of the Transfer-Encoding header: gzip, compress, deflate, identity, *

155 questions
111
votes
2 answers

Transfer-Encoding: gzip vs. Content-Encoding: gzip

What is the current state of affairs when it comes to whether to do Transfer-Encoding: gzip or a Content-Encoding: gzip when I want to allow clients with e.g. limited bandwidth to signal their willingness to accept a compressed response and the…
Evgeniy Berezovsky
  • 18,571
  • 13
  • 82
  • 156
110
votes
5 answers

Android: HTTP communication should use "Accept-Encoding: gzip"

I've a HTTP communication to a webserver requesting JSON data. I'd like compress this data stream with Content-Encoding: gzip. Is there a way I can set Accept-Encoding: gzip in my HttpClient? The search for gzip in the Android References doesn't…
znq
  • 44,613
  • 41
  • 116
  • 144
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
34
votes
8 answers

How can I pre-compress files with mod_deflate in Apache 2.x?

I am serving all content through apache with Content-Encoding: zip but that compresses on the fly. A good amount of my content is static files on the disk. I want to gzip the files beforehand rather than compressing them every time they are…
Otto
  • 18,761
  • 15
  • 56
  • 62
23
votes
1 answer

How can I accept gzip-compressed content using LWP::UserAgent?

I am fetching some pages over the Web using Perl's LWP::UserAgent and would like to be as polite as possible. By default, LWP::UserAgent does not seamlessly handle compressed content via gzip. Is there an easy way to make it do so, to save everyone…
Ryan Tate
  • 1,553
  • 2
  • 14
  • 21
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
15
votes
2 answers

Accept-Encoding:gzip and Content-Encoding:gzip

What is the difference between the two HTTP headers? Accept-Encoding:gzip Content-Encoding:gzip
Sardar
  • 524
  • 1
  • 6
  • 19
15
votes
2 answers

Handling HTTP ContentEncoding "deflate"

What InputStream type should be used to handle URLConnection streams that have HTTP Content-Encoding set to deflate? For a Content-Encoding of gzip or zip I use a GZIPInputStream, no problem. For a Content-Encoding of "deflate" I have tried using…
Joel
  • 29,538
  • 35
  • 110
  • 138
15
votes
2 answers

How can content-encoding be ignored

I have a device I need to download a file from. In certain cases, the file may have an incorrect content-encoding. Particularly, it may have a content-encoding of "gzip", when it is not gzipped, or compressed in any way. So, when the file is…
femtoRgon
  • 32,893
  • 7
  • 60
  • 87
12
votes
2 answers

PHP ob_start() and ob_start('ob_gzhandler')

What is the difference between using ob_start() and ob_start('ob_gzhandler') ? How does it affect the page speed ?
Sithu
  • 4,752
  • 9
  • 64
  • 110
10
votes
1 answer

HTTP content encoding, base64

Is there any way to know if the message body of an HTTP response is encoded with Base64? I learnt that content-transfer-encoding is not part of HTTP header. So, which HTTP header indicates that the content is encoded with Base64? I think…
Anant
  • 109
  • 1
  • 2
  • 5
7
votes
1 answer

Is it possible to use Content-Encoding: gzip in a HTTP POST request?

I'm trying to upload some files with compression to a server. The files will be fairly large and the server is a standard HTTP server where the interface defines that they're not compressed. Is it possible to use something like Content-Encoding to…
dascandy
  • 7,184
  • 1
  • 29
  • 50
7
votes
3 answers

How do HTTP proxy caches decide between serving identity- vs. gzip-encoded resources?

An HTTP server uses content-negotiation to serve a single URL identity- or gzip-encoded based on the client's Accept-Encoding header. Now say we have a proxy cache like squid between clients and the httpd. If the proxy has cached both encodings of a…
Steve Clay
  • 8,671
  • 2
  • 42
  • 48
7
votes
3 answers

GZIP compression using zlib into buffer

I want to compress a memory buffer using gzip and put the compressed bytes into another memory buffer. I want to send the compressed buffer in the payload of a HTTP packet with Content-Encoding: gzip. I can easily do this using zlib for deflate…
Sh00nya
  • 71
  • 1
  • 2
7
votes
1 answer

sending content-encoding header in django

Hello I want to have a plaintext version of my content available. So I have a separate template for that. I am calling render_to_response with mimetype="text/plain" but i want to tell a browser opening that page in the http-response that the content…
niklasfi
  • 15,245
  • 7
  • 40
  • 54
1
2 3
10 11