rocket_seek_stream
A Rocket responder for types implementing the Read + Seek
traits, such as files and std::io::Cursor
, that will respond to range requests with a 206 Partial Content response. The Content-Type
can optionally be inferred by taking a sample of bytes from the beginning of the stream, or given manually. An Accept-Ranges: bytes
header will be sent in all responses to notify browsers that range requests are supported for the resource.
This supports both single and multipart/byterange requests. https://tools.ietf.org/html/rfc7233
Cargo.toml
Add this to your dependencies.
rocket_seek_stream = {git="https://github.com/rydz/rocket_seek_stream"}
Examples
Serving a file from the disk
extern crate rocket;
use SeekStream;
Serving an in memory buffer
Use cargo run --example server
to run the example. run examples/download.sh
to download the media it depends on using youtube-dl.
TODO
- Write some tests
I've compared the output of the Golang stdlib http router's multipart response to what I output here and it looks about the same except for a small difference in whitespace.