12

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.

5
  • I think this thread is similar to what your looking for security.stackexchange.com/questions/3989/… Commented Nov 7, 2012 at 8:41
  • 1
    why do you want to encode in base64 anyway? Commented Nov 7, 2012 at 10:33
  • I am the proxy and want to check for the traffic. I whole intention is see HTTP packet, check whether the content is encoded or not. Commented Nov 7, 2012 at 11:27
  • Anant: so the answer is: there is nothing specific to base64 in HTTP Commented Nov 7, 2012 at 13:06
  • More specifically: a base64 content-coding parameter is not registered; you should not have to expect nor implement it. If no Content-Encoding-header is present, you may assume the data in the message body is transferred as-is. Commented Nov 7, 2012 at 13:24

1 Answer 1

10

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.

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

4 Comments

Is it same with older HTTP versions?
Anant: yes, there never was base64 in HTTP
@Anant you say in a comment under your question that you're implementing an HTTP proxy. If you're doing so, I'd figure you'd know your way into and around the HTTP and related RFC's. The same text is present in the HTTP/1.0 RFC as well as the HTTP/1.1 RFC.
I've actually seen YouTube transmit data as Base64, when I wrote a comment with Firefox's network debugger open and looked at the answer contents which looked like JSON but flipping the "Raw" switch made it appear in Base64, so how did the browser know that was JSON? Note: I couldn't find any header that told me that so either the debugger is good at guessing or there were some other shenanigans going on in the background.

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.