File Transfer over HTTP

As far as I know, you can transfer binary files using the HTTP protocol. But HTTP is a text protocol, the standard HTTP response frame is 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 the binary be encoded in this frame? What is Content-Type? Is base64 encoded content the same as POP3 attachments? Or is it raw data (can you not cause problems if this is so?)

+6
source share
2 answers

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

And no, this has nothing to do with Content-Type. This is just a shortcut so that the recipient knows how to process the data; this does not affect the format in the protocol itself.

+9
source

Binary files are usually transferred with the file type of the application / octet stream (unless, of course, they do not coincide with another more specific type of playback). You use raw data for the transfer - base64 is not required.

0
source

Source: https://habr.com/ru/post/916485/


All Articles