Add exact resumable HTTP source streaming
This commit is contained in:
parent
3041257d78
commit
5b43b6c660
1 changed files with 1361 additions and 5 deletions
|
|
@ -1,4 +1,4 @@
|
|||
use std::{fmt, net::SocketAddr};
|
||||
use std::{fmt, net::SocketAddr, time::Duration};
|
||||
|
||||
use http::{HeaderMap, HeaderName, Method, StatusCode};
|
||||
use reqwest::{Certificate, redirect::Policy};
|
||||
|
|
@ -18,6 +18,7 @@ pub struct OutboundClient<R> {
|
|||
resolver: R,
|
||||
policy: OutboundPolicy,
|
||||
roots: Vec<Certificate>,
|
||||
connect_timeout: Option<Duration>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
|
|
@ -54,6 +55,7 @@ impl<R: Resolver> OutboundClient<R> {
|
|||
resolver,
|
||||
policy,
|
||||
roots: Vec::new(),
|
||||
connect_timeout: None,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
@ -109,6 +111,9 @@ impl<R: Resolver> OutboundClient<R> {
|
|||
let mut builder = reqwest::Client::builder()
|
||||
.redirect(Policy::none())
|
||||
.no_proxy();
|
||||
if let Some(connect_timeout) = self.connect_timeout {
|
||||
builder = builder.connect_timeout(connect_timeout);
|
||||
}
|
||||
if url.literal_address().is_none() {
|
||||
builder = builder.resolve(
|
||||
url.host_str(),
|
||||
|
|
@ -123,6 +128,12 @@ impl<R: Resolver> OutboundClient<R> {
|
|||
}
|
||||
|
||||
impl<R> OutboundClientBuilder<R> {
|
||||
#[must_use]
|
||||
pub fn connect_timeout(mut self, timeout: Duration) -> Self {
|
||||
self.client.connect_timeout = Some(timeout);
|
||||
self
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn add_root_certificate(mut self, certificate: Certificate) -> Self {
|
||||
self.client.roots.push(certificate);
|
||||
|
|
|
|||
Loading…
Reference in a new issue