Audrius Meškauskas
Audrius Meškauskas

Reputation: 21728

Can I send binary data directly over 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.

Upvotes: 11

Views: 12622

Answers (2)

Julian Reschke
Julian Reschke

Reputation: 41997

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

Upvotes: 12

Gumbo
Gumbo

Reputation: 655129

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.

Upvotes: 9

Related Questions