7

As far as I know it is possible to transfer binary files over HTTP protocol. But HTTP is a text-based protocol, the typical HTTP response frame looks as follows:

HTTP/1.1 200 OK
Date: Wed, 23 May 2012 22:38:34 GMT
Content-Length: 438
Content-Type: text/html; charset=UTF-8

Here goes content

If so, how should binary file be encoded in this frame? What is the Content-Type? Is the content encoded with base64 - same as attachments in POP3 protocol? Or it is raw data (is it possible not to cause problems if so?)

Marc Andreson
  • 3,405
  • 5
  • 35
  • 51

2 Answers2

9

The header fields are text based, but the actual payload is binary. You can transfer whatever you want.

And no, it doesn't have anything to do with the Content-Type. That is just a label so that the recipient knows how to process the data; it does not affect the format in the protocol itself.

Julian Reschke
  • 40,156
  • 8
  • 95
  • 98
0

Binary files are usually transferred with the Application/octet-stream mimetype (unless they match another more specific mimetype of course). For transmission you use the raw data - no base64 needed.

Pierre
  • 874
  • 6
  • 8