Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I send binary data directly over HTTP?

Tags:

http

I mean, can I expect to work

POST / HTTP/1.1
Content-Type: application/octet-stream
Content-Length: 27

[27 bytes of binary data]

And the binary data is arbitrary binary data, not Base64 encoded with all 8 bits in use, not 7 bits. The receiving application is custom application that would know what to do with the data.

Of course, I could test, but I need to know if this is likely to work with real server and over web, not just between both client and server running on a localhost.

like image 676
Audrius Meškauskas Avatar asked Aug 23 '14 08:08

Audrius Meškauskas


Video Answer


2 Answers

Yes. HTTP/1.1 message header blocks are text, but the payload of messages can be arbitrary binary data.

like image 117
Julian Reschke Avatar answered Sep 23 '22 00:09

Julian Reschke


RFC 2046 defines the octet-stream subtype as follows:

4.5.1. Octet-Stream Subtype

The "octet-stream" subtype is used to indicate that a body contains arbitrary binary data.

And RFC 2045 defines binary data in context of MIME messages as follows:

2.9. Binary Data

"Binary data" refers to data where any sequence of octets whatsoever is allowed.

like image 38
Gumbo Avatar answered Sep 25 '22 00:09

Gumbo