HTTP receive encoding and sending unencoded data

I am creating a module for compressing HTTP output. While reading the spec , I did not find a clear difference in a few things:

Accept-Encoding:

Should this be handled in the same way as Accept-Encoding: * , or as if no header was present?

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

Accept-Encoding: gzip

Should I return 406 error or just return data not assigned?

EDIT:

I read the spec several times. It mentions my first case, but it does not determine what the server behavior should be.

Should I treat this case as if the title is missing? Or should I return a 406 error because there is no way to encode something based on a field value ('' is not a valid encoding).

+4
source share
1 answer

Everything is written in Spec: 14.3 Accept-Encoding :

The special character "*" in the Accept-Encoding field matches any available encoding content not explicitly specified in the header field.

If the request contains the Accept-Encoding field, and if the server cannot send a response that is acceptable according to the Accept-Encoding header, then the server MUST send an error response with the status 406 (invalid) code.

edit:

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

In this case, if the “identifier” is one of the available content encodings, then the server MUST use the “identifier” content encoding, unless it has additional information that the client has a different encoding of the content.

What is identification

identity
Default encoding (identification); the use of any transformations in general. This content encoding is used only in the Accept-Encoding header and MUST NOT be used in the Content-Encoding header.

+7
source

All Articles