Module http

Module http 

Source
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_clientreqwest
Adapters for using reqwest with stream-download

Structs§

ContentType
Represents the content type HTTP response header
HttpStream
An HTTP implementation of the SourceStream trait.

Enums§

HttpStreamError
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 reqwest feature is enabled, this trait is implemented for reqwest::Client. This can be implemented for a custom HTTP client if desired.
ClientResponse
A wrapper trait for an HTTP response that exposes only functionality necessary for retrieving the stream content. If the reqwest feature is enabled, this trait is implemented for reqwest::Response. This can be implemented for a custom HTTP response if desired.
ResponseHeaders
A trait for getting a specific header value

Functions§

format_range_header_bytes
Utility function to format a range header for requesting bytes.