HTTP content encoding, base64

Anant picture Anant · Nov 7, 2012 · Viewed 14.8k times · Source

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 Content-encoding is only used for compressions.

Answer

CodeCaster picture CodeCaster · Nov 7, 2012

As far as I understand, an HTTP body may not be encoded in Base64:

HTTP does not use the Content-Transfer-Encoding (CTE) field of RFC 2045. Proxies and gateways from MIME-compliant protocols to HTTP MUST remove any non-identity CTE ("quoted-printable" or "base64") encoding prior to delivering the response message to an HTTP client.

Identity being:

The default (identity) encoding; the use of no transformation whatsoever.

Of course you're allowed to transport Base64-encoded data using HTTP, but that should be something both parties (client and server) agree on, and there doesn't seem to be a header to describe this behavior.