Available on crate feature
http only.Expand description
An HTTP implementation of the SourceStream trait.
An implementation of the Client trait using reqwest
is provided if the reqwest feature is enabled. If you need to customize the client object, you
can use HttpStream::new to supply your own reqwest client.
Keep in mind that reqwest recommends creating a single client and cloning it for each new
connection.
§Example
use std::error::Error;
use std::result::Result;
use stream_download::http::HttpStream;
use stream_download::http::reqwest::Client;
use stream_download::source::SourceStream;
#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
let stream = HttpStream::new(
Client::new(),
"https://some-cool-url.com/some-file.mp3".parse()?,
)
.await?;
let content_length = stream.content_length();
Ok(())
}Re-exports§
pub use reqwest;reqwest
Modules§
- reqwest_
client reqwest - Adapters for using
reqwestwithstream-download
Structs§
- Content
Type - Represents the content type HTTP response header
- Http
Stream - An HTTP implementation of the
SourceStreamtrait.
Enums§
- Http
Stream Error - Error returned from an HTTP stream.
Constants§
- RANGE_
HEADER_ KEY - HTTP range header key
Traits§
- Client
- Wrapper trait for an HTTP client that exposes only functionality necessary for retrieving the
stream content. If the
reqwestfeature is enabled, this trait is implemented for reqwest::Client. This can be implemented for a custom HTTP client if desired. - Client
Response - A wrapper trait for an HTTP response that exposes only functionality necessary for retrieving
the stream content. If the
reqwestfeature is enabled, this trait is implemented for reqwest::Response. This can be implemented for a custom HTTP response if desired. - Response
Headers - A trait for getting a specific header value
Functions§
- format_
range_ header_ bytes - Utility function to format a range header for requesting bytes.