Questions tagged [http-accept-encoding]

The Accept-Encoding request-header field is similar to Accept, but restricts the content-codings (section 3.5) that are acceptable in the response.

The Accept-Encoding request-header field is similar to Accept, but restricts the content-codings that are acceptable in the response.

   Accept-Encoding  = "Accept-Encoding" ":"
                      1#( codings [ ";" "q" "=" qvalue ] )
   codings          = ( content-coding | "*" )

Examples of its use are:

   Accept-Encoding: compress, gzip
   Accept-Encoding:
   Accept-Encoding: *
   Accept-Encoding: compress;q=0.5, gzip;q=1.0
   Accept-Encoding: gzip;q=1.0, identity; q=0.5, *;q=0

A server tests whether a content-coding is acceptable, according to an Accept-Encoding field, using these rules:

  1. If the content-coding is one of the content-codings listed in the Accept-Encoding field, then it is acceptable, unless it is accompanied by a qvalue of 0. (As defined in section 3.9, a qvalue of 0 means "not acceptable.")
  2. The special "*" symbol in an Accept-Encoding field matches any available content-coding not explicitly listed in the header field.
  3. If multiple content-codings are acceptable, then the acceptable content-coding with the highest non-zero qvalue is preferred.
  4. The "identity" content-coding is always acceptable, unless specifically refused because the Accept-Encoding field includes "identity;q=0", or because the field includes "*;q=0" and does not explicitly include the "identity" content-coding. If the Accept-Encoding field-value is empty, then only the "identity" encoding is acceptable.

If an Accept-Encoding field is present in a request, and if the server cannot send a response which is acceptable according to the Accept-Encoding header, then the server SHOULD send an error response with the 406 (Not Acceptable) status code.

If no Accept-Encoding field is present in a request, the server MAY assume that the client will accept any content coding. In this case, if "identity" is one of the available content-codings, then the server SHOULD use the "identity" content-coding, unless it has additional information that a different content-coding is meaningful to the client.

Note: If the request does not include an Accept-Encoding field, and if the "identity" content-coding is unavailable, then content-codings commonly understood by HTTP/1.0 clients (i.e., "gzip" and "compress") are preferred; some older clients improperly display messages sent with other content-codings.
The server might also make this decision based on information about the particular user-agent or client.

Note: Most HTTP/1.0 applications do not recognize or obey qvalues associated with content-codings. This means that qvalues will not work and are not permitted with x-gzip or x-compress.

31 questions
20
votes
6 answers

How to return gzipped content with AWS API Gateway

We have developed an application that offers serveral rest services and supports Accept-Encoding header to return compressed content through Content-Encoding:gzip header value. This application is deployed on ec2 instances on aws and when we send a…
althor
  • 739
  • 2
  • 9
  • 21
20
votes
3 answers

What is the canonical method for an HTTP client to instruct an HTTP server to disable gzip responses?

I thought this was a simple google search, but apparently I'm wrong on that. I've seen that you should supply: Accept-Encoding: gzip;q=0,deflate;q=0 in the request headers. However, the article that suggested it also noted that proxies routinely…
Homer6
  • 15,034
  • 11
  • 61
  • 81
11
votes
1 answer

Does Chrome support Brotli? (Accept-Encoding does not contain br)

Can I use page says that Chrome supports brotli for some time now. I would think that the Accept-Encoding string would be like this: Accept-Encoding:gzip, deflate, sdch, br But I checked on a request to StackOverflow e.g. and it does not contain…
Ilya Chernomordik
  • 27,817
  • 27
  • 121
  • 207
8
votes
1 answer

plain text in Accept-Encoding HTTP Header

I'm writing a HTTP client which doesn't have any encoding algorithms built into it yet. Therefore, I was wondering if there is a value for Accept-Encoding header to indicate this? like: "none" for example, or "text/plain" or similar ?
astralmaster
  • 2,344
  • 11
  • 50
  • 84
7
votes
1 answer

Does Alamofire by default request for gzipped response?

I am using Alamofire for networking in my project. As my server support gzipped response. I wanted to know whether Alamofire in itself support gzip or do i need to exclusively set in its header as ["Accept-Encoding":"gzip"]. I tried both the cases…
Shobhit C
  • 828
  • 10
  • 15
6
votes
5 answers

restsharp accept-encoding disabling compression

In a particular case I need to be able to disable compression in the requst/response. Using Firefox RestClient I am able to post some xml to a web service and get some response xml successfully with a single header parameter "Accept-Encoding" : "…
user3801443
  • 61
  • 1
  • 3
3
votes
0 answers

ASP.NET Core disable Content-Encoding on individually action responses

How is it possible to disable the Content-Encoding for an individual controller action in ASP.NET Core (v1.0.1) I already tried: public FileResult Index(){ // HttpContext.Request.Headers["Accept-Encoding"] = ""; return…
Ole K
  • 754
  • 1
  • 9
  • 32
3
votes
2 answers

Why does the XMLHttpRequest spec prevent setting the Accept-Encoding header?

Today, I wanted to utilize the Accept-Encoding header to request an image as base64. Come to find out, the XMLHttpRequest spec prevents setting that header! http://www.w3.org/TR/XMLHttpRequest/#the-setrequestheader()-method Note: The above headers…
3
votes
1 answer

http: minimum content-encoding support for clients?

Is there a minimum set of content-encodings that a http client must support? Restated: Is a client that only implements content-encoding:identity conformant with standards? I can't find clear documentation on the subject.
bukzor
  • 37,539
  • 11
  • 77
  • 111
3
votes
1 answer

Is it valid to leave Accept-Encoding field empty?

I found the example of Accept-Encoding violates the specification in the document: http://www.w3.org/Protocols/rfc2616/rfc2616-sec14#sec14.3 The "Accept-Encoding" header field is defined as below: Accept-Encoding = "Accept-Encoding" ":" …
shuangwhywhy
  • 5,475
  • 2
  • 18
  • 28
2
votes
0 answers

Disabling compression on HTTP requests

I have a web service that a customer calls with no Accept-Encoding header today. By default, IIS gzips responses back unless the server is under too much load, in which case the responses go back uncompressed (as is consistent with the spec): The…
Killnine
  • 5,728
  • 8
  • 39
  • 66
2
votes
0 answers

How to handle GZIP, Deflate accept encoding in Mule

How does mule handle GZIP, Deflate Accept Encoding Headers? Is it automatic or do we need to use the GZIP Compress connector or do we need to do something else when the application receives this as a header? I am using Mule 3.8.1 and Anypoint…
user3165854
  • 1,505
  • 8
  • 48
  • 100
2
votes
1 answer

What does "Accept-Encoding: *" mean?

This page on Mozilla Developer Network, which is usually not too bad in quality, states: * matches any content encoding not already listed in the header. This is the default value if the header is not present. It doesn't mean that any algorithm is…
AndreKR
  • 32,613
  • 18
  • 106
  • 168
2
votes
0 answers

Apache serve compressed/uncompressed files depending on Accept-Encoding header

The following question is highly related to this one. Apache version is 2.2, so no "If" statement is provided. The server contains only gzipped files, in order to save space. A user can request the gzipped file or just its decompressed content,…
mr.G
  • 167
  • 1
  • 1
  • 10
1
vote
0 answers

How to use ungzip on a fetch in Google Apps Script?

I'm trying to fetch a large JSON in Google Script but end up with a truncated response since it hit the 50Mb maximum fetch response size. So I'm now trying to get it compressed since in my browser the request takes only 12Mb but can't find a way to…
1
2 3