Question

I'm wondering if the following idea is working against the spirit and/or letter of HTTP Content Negotiation and HTTP Compression.

The Situation

The HTTP Client requests a resource:

HTTP GET /image.jpeg HTTP/1.1
Accept: image/jpeg

The HTTP Server returns this resource:

HTTP/1.1 200 OK
Content-Type: image/jpeg

The Idea

The Client thinks it's a good idea to request the resource encoded:

HTTP GET /image.jpeg HTTP/1.1
Accept: image/jpeg
Accept-Encoding: base64

The Server honors this request and returns the resource encoded:

HTTP/1.1 200 OK
Content-Type: image/jpeg
Content-Encoding: base64

The Question

I'm not quite happy with this idea. HTTP Compression, for which the Accept-Encoding and Content-Encoding headers are used, is about compressing data, not about increasing its size as Base64 does.

Is the use of base64 as a value for these headers a violation of the spirit and/or letter of HTTP Content Negotiation and HTTP Content Compression?

Was it helpful?

Solution

RFC 2616 section 3.5 (emphasis mine):

Content codings are primarily used to allow a document to be compressed or otherwise usefully transformed without losing the identity of its underlying media type and without loss of information.

Your idea is perfectly in line with the “spirit and letter” of HTTP.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top