application/octet-stream application/octet-stream means: application/octet-stream is the media type for arbitrary binary data whose specific format is unknown or intentionally opaque. It is the generic fallback of the MIME system: receivers treat the bytes as a raw stream, and browsers typically trigger a download rather than inline rendering. Application media types carry structured or binary data that a program consumes rather than a human reading raw bytes. The subtype tells the receiver exactly which parser, decoder or handler to invoke, so sending the correct Content-Type is part of the API contract: a mismatch makes servers reject the body with 415 Unsupported Media Type or clients mis-parse the payload. You will encounter application/octet-stream in contexts such as unknown or proprietary binary file downloads; executable installers and disk images served as save-as files; fallback when a server cannot determine a more specific type. It is commonly associated with the file extension(s) .bin, .exe, .dmg. Overusing octet-stream is an anti-pattern: it discards type information that clients could use to handle content correctly. Declare a specific registered type whenever you know it, and reserve octet-stream for genuinely opaque binaries or deliberate download behavior.
When you'll see application/octet-stream
- Unknown or proprietary binary file downloads
- Executable installers and disk images served as save-as files
- Fallback when a server cannot determine a more specific type
How to handle it
When handling an application type, set the Content-Type header explicitly on every request and response that carries a body, and advertise what you accept with the Accept header. Parse the payload with a library that matches the subtype rather than sniffing bytes, and validate the structure before trusting it. If a server returns 415, the declared type does not match what it expects — compare your header against the API documentation character for character, including parameters such as charset or boundary. As a final checklist for application types: register the exact subtype in your API documentation, validate incoming bodies against a schema before use, set X-Content-Type-Options: nosniff to stop MIME sniffing, and version your media types when the payload contract changes so old clients keep working.
Notes & gotchas
Overusing octet-stream is an anti-pattern: it discards type information that clients could use to handle content correctly. Declare a specific registered type whenever you know it, and reserve octet-stream for genuinely opaque binaries or deliberate download behavior.
Examples
HTTP/1.1 200 OK
Content-Type: application/octet-stream
Content-Disposition: inline; filename="sample.bin"
[binary application payload: the encoded bytes of a sample .bin] curl -i -H "Accept: application/octet-stream" https://api.example.com/v1/resource # inspect the returned Content-Type const res = await fetch("/v1/resource", { headers: { Accept: "application/octet-stream" } });
// verify res.headers.get("Content-Type") starts with "application/octet-stream"
const text = await res.text(); // handle according to the declared type import requests
res = requests.get("https://api.example.com/v1/resource",
headers={"Accept": "application/octet-stream"}, timeout=30)
res.raise_for_status()
assert res.headers["Content-Type"].startswith("application/octet-stream")
with open("sample.bin", "wb") as fh:
fh.write(res.content) # raw bytes; use stream=True for large files Frequently asked questions
Why does my file download instead of opening?
Because it is served as application/octet-stream, which signals opaque binary and prompts a save-as. Use the specific type plus Content-Disposition: inline if you want browser handling.
Is octet-stream a security risk?
It can be: browsers may sniff content and execute it in some contexts. Set X-Content-Type-Options: nosniff and a deliberate Content-Disposition to control how opaque binaries are handled.
What happens if I send the wrong application Content-Type?
Servers that validate media types answer 415 Unsupported Media Type, and clients may parse the body with the wrong decoder. Always set Content-Type to the registered type that matches your payload, and set Accept to the types you can handle.
Is application/octet-stream a safe default?
It means 'arbitrary binary bytes' and forces a download rather than inline handling. Use it only when the real type is unknown or you deliberately want a save-as dialog; otherwise declare the specific registered type.
How do I debug a 415 Unsupported Media Type response?
Compare the Content-Type you actually sent against what the endpoint documents, including parameters like charset and boundary. A 415 means the server refuses that media type; send the exact registered type it accepts and retry.
Try the Base64 Encoder
Encode and decode Base64 with UTF-8 and URL-safe options.