Data Application Octet Stream
This data set approximates polygon boundaries for zip codes within Minnesota. The polygon boundaries are approximate since the U.S. Postal Service assigns zip codes.
The HTTP standard says:
If this header [Content-Disposition: attachment] is used in a response with the application/octet-stream content-type, the implied suggestion is that the user agent should not display the response, but directly enter a `save response as..' dialog.
I read that as
But I would have thought that Content-Type
would be application/pdf
, image/png
, etc.
Should I have Content-Type: application/octet-stream
if I want browsers to download the file?
1 Answer
No.
The content-type should be whatever it is known to be, if you know it. application/octet-stream
is defined as 'arbitrary binary data' in RFC 2046, and there's a definite overlap here of it being appropriate for entities whose sole intended purpose is to be saved to disk, and from that point on be outside of anything 'webby'. Or to look at it from another direction; the only thing one can safely do with application/octet-stream is to save it to file and hope someone else knows what it's for.
You can combine the use of Content-Disposition
with other content-types, such as image/png
or even text/html
to indicate you want saving rather than display. It used to be the case that some browsers would ignore it in the case of text/html
but I think this was some long time ago at this point (and I'm going to bed soon so I'm not going to start testing a whole bunch of browsers right now; maybe later).
RFC 2616 also mentions the possibility of extension tokens, and these days most browsers recognise inline
to mean you do want the entity displayed if possible (that is, if it's a type the browser knows how to display, otherwise it's got no choice in the matter). This is of course the default behaviour anyway, but it means that you can include the filename
part of the header, which browsers will use (perhaps with some adjustment so file-extensions match local system norms for the content-type in question, perhaps not) as the suggestion if the user tries to save.
Hence:
Means 'I don't know what the hell this is. Please save it as a file, preferably named picture.png'.
Means 'This is a PNG image. Please save it as a file, preferably named picture.png'.
Means 'This is a PNG image. Please display it unless you don't know how to display PNG images. Otherwise, or if the user chooses to save it, we recommend the name picture.png for the file you save it as'.
Jquery Ajax Data Type Application/octet-stream
Of those browsers that recognise inline
some would always use it, while others would use it if the user had selected 'save link as' but not if they'd selected 'save' while viewing (or at least IE used to be like that, it may have changed some years ago).
protected by Rachel GallenMar 15 at 8:50
Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?
Not the answer you're looking for? Browse other questions tagged httpbrowserhttp-headersdownload or ask your own question.
A bitstream (or bit stream), also known as binary sequence, is a sequence of bits.
Hindi mashup songs. A bytestream is a sequence of bytes. Typically, each byte is an 8-bit quantity (octets), and so the term octet stream is sometimes used interchangeably. An octet may be encoded as a sequence of 8 bits in multiple different ways (see endianness) so there is no unique and direct translation between bytestreams and bitstreams.
Bitstreams and bytestreams are used extensively in telecommunications and computing. For example, synchronous bitstreams are carried by SONET, and Transmission Control Protocol transports an asynchronous bytestream.
Relationship between bitstreams and bytestreams[edit]
In practice, bitstreams are not used directly to encode bytestreams; a communication channel may use a signalling method that does not directly translate to bits (for instance, by transmitting signals of multiple frequencies) and typically also encodes other information such as framing and error correction together with its data.[citation needed]
Examples[edit]
The term bitstream is frequently used to describe the configuration data to be loaded into a field-programmable gate array (FPGA). Although most FPGAs also support a byte-parallel loading method as well, this usage may have originated based on the common method of configuring the FPGA from a serial bit stream, typically from a serial PROM or flash memory chip. The detailed format of the bitstream for a particular FPGA is typically proprietary to the FPGA vendor.
In mathematics, several specific infinite sequences of bits have been studied for their mathematical properties; these include the Baum–Sweet sequence, Ehrenfeucht–Mycielski sequence, Fibonacci word, Kolakoski sequence, regular paperfolding sequence, Rudin–Shapiro sequence, and Thue–Morse sequence.
On most operating systems, including Unix-like and Windows, standard I/O libraries convert lower-level paged or buffered file access to a bytestream paradigm. In particular in Unix-like operating systems, each process has three standard streams, that are examples of unidirectional bytestreams. The Unix pipe mechanism provides bytestream communications between different processes.
Compression algorithms often code in bitstreams, as the 8 bits offered by a byte (the smallest addressable unit of memory) may be wasteful. Although typically implemented in low-level languages, some high-level languages such as Python[1] and Java[2] offer native interfaces for bitstream I/O.
One well-known example of a communication protocol which provides a byte-stream service to its clients is the Transmission Control Protocol (TCP) of the Internet protocol suite, which provides a bidirectional bytestream.
The Internet media type for an arbitrary bytestream is application/octet-stream. Other media types are defined for bytestreams in well-known formats.
Flow control[edit]
Often the contents of a bytestream are dynamically created, such as the data from the keyboard and other peripherals (/dev/tty), data from the pseudorandom number generator (/dev/urandom), etc.
In those cases, when the destination of a bytestream (the consumer) uses bytes faster than they can be generated, the system uses process synchronization to make the destination wait until the next byte is available.
When bytes are generated faster than the destination can use them, there are several techniques to deal with the situation:
- When the producer is a software algorithm, the system pauses the producer with the same process synchronization techniques
- When the producer supports flow control, the system only sends the ready signal when the consumer is ready for the next byte
- When the producer can't be paused—it is a keyboard or some hardware that doesn't support flow control—the system typically attempts to temporarily store the data until the consumer is ready for it, typically using a queue. Often the receiver can empty the buffer before it gets completely full. A producer that continues to produce data faster than it can be consumed, even after the buffer is full, leads to unwanted buffer overflow, packet loss, and network congestion.
See also[edit]
References[edit]
- ^'Bitstream'. Archived from the original on 2016-09-08.
- ^'Class BitSet'. Archived from the original on 2016-11-30.