6

I building a module for compressing HTTP output. Reading the spec, I haven't found a clear distinction on a couple of things:

Accept-Encoding:

Should this be treated the same as a Accept-Encoding: * or as if no header is present?

Or what if I don't support gzip, but I get a header like this:

Accept-Encoding: gzip

Should I return a 406 error or just return the data unencoded?

EDIT:

I've read over the spec a few times. It mentions my first case, but it doesn't define what the behavior of the server should be.

Should I treat this case as if the header is not present? Or should I return a 406 error because there's no way to encode something given the field value ('' isn't a valid encoding).

0

1 Answer 1

8

There is written everything in the Spec: 14.3 Accept-Encoding:

The special "*" symbol in an Accept-Encoding field matches any available content-coding not explicitly listed in the header field.

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.

edit:

If the Accept-Encoding field-value is empty, then only the "identity" encoding is acceptable.

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.

What is "identity"

identity
The default (identity) encoding; the use of no transformation whatsoever. This content-coding is used only in the Accept- Encoding header, and SHOULD NOT be used in the Content-Encoding header.

Sign up to request clarification or add additional context in comments.

6 Comments

I think you missed my point. If I have an Accept-Encoding field, but it is empty, is that treated like a * symbol or should I return a 406 error?
If I have an Accept-Encoding field, but it is empty. Is that not clear? I don't think the spec specifies...
Sorry, you are right, its late... But there is written something about the "identity" encoding, I edit my answer
What is the "identity" encoding? Does this mean whatever the file was initially without any change whatsoever?
I think its the server default value, which you can set in the config of the webserver (apache for example)
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.