Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

File transfer over HTTP

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?)

like image 466
Marc Andreson Avatar asked May 23 '12 18:05

Marc Andreson


1 Answers

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.

like image 80
Julian Reschke Avatar answered Oct 07 '22 21:10

Julian Reschke