Add missing pub(crate) statements.
This commit is contained in:
committed by
Sean McArthur
parent
4857a5917d
commit
647f59756e
@@ -146,38 +146,36 @@ impl fmt::Debug for Chunk {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// pub(crate)
|
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn wrap(body: ::hyper::Body) -> Body {
|
pub(crate) fn wrap(body: ::hyper::Body) -> Body {
|
||||||
Body {
|
Body {
|
||||||
inner: Inner::Hyper(body),
|
inner: Inner::Hyper(body),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn empty() -> Body {
|
pub(crate) fn empty() -> Body {
|
||||||
Body {
|
Body {
|
||||||
inner: Inner::Hyper(::hyper::Body::empty()),
|
inner: Inner::Hyper(::hyper::Body::empty()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn chunk(chunk: Bytes) -> Chunk {
|
pub(crate) fn chunk(chunk: Bytes) -> Chunk {
|
||||||
Chunk {
|
Chunk {
|
||||||
inner: ::hyper::Chunk::from(chunk)
|
inner: ::hyper::Chunk::from(chunk)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn reusable(chunk: Bytes) -> Body {
|
pub(crate) fn reusable(chunk: Bytes) -> Body {
|
||||||
Body {
|
Body {
|
||||||
inner: Inner::Reusable(chunk),
|
inner: Inner::Reusable(chunk),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn into_hyper(body: Body) -> (Option<Bytes>, ::hyper::Body) {
|
pub(crate) fn into_hyper(body: Body) -> (Option<Bytes>, ::hyper::Body) {
|
||||||
match body.inner {
|
match body.inner {
|
||||||
Inner::Reusable(chunk) => (Some(chunk.clone()), chunk.into()),
|
Inner::Reusable(chunk) => (Some(chunk.clone()), chunk.into()),
|
||||||
Inner::Hyper(b) => (None, b),
|
Inner::Hyper(b) => (None, b),
|
||||||
|
|||||||
@@ -304,7 +304,7 @@ impl<R: Read> Read for Peeked<R> {
|
|||||||
|
|
||||||
impl<S> ReadableChunks<S> {
|
impl<S> ReadableChunks<S> {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn new(stream: S) -> Self {
|
pub(crate) fn new(stream: S) -> Self {
|
||||||
ReadableChunks {
|
ReadableChunks {
|
||||||
state: ReadState::NotReady,
|
state: ReadState::NotReady,
|
||||||
stream: stream,
|
stream: stream,
|
||||||
@@ -387,15 +387,13 @@ impl<S> ReadableChunks<S>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// pub(crate)
|
|
||||||
|
|
||||||
/// Constructs a Decoder from a hyper request.
|
/// Constructs a Decoder from a hyper request.
|
||||||
///
|
///
|
||||||
/// A decoder is just a wrapper around the hyper request that knows
|
/// A decoder is just a wrapper around the hyper request that knows
|
||||||
/// how to decode the content body of the request.
|
/// how to decode the content body of the request.
|
||||||
///
|
///
|
||||||
/// Uses the correct variant by inspecting the Content-Encoding header.
|
/// Uses the correct variant by inspecting the Content-Encoding header.
|
||||||
pub fn detect(headers: &mut HeaderMap, body: Body, check_gzip: bool) -> Decoder {
|
pub(crate) fn detect(headers: &mut HeaderMap, body: Body, check_gzip: bool) -> Decoder {
|
||||||
if !check_gzip {
|
if !check_gzip {
|
||||||
return Decoder::plain_text(body);
|
return Decoder::plain_text(body);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -164,6 +164,7 @@ impl<T: Into<body::Body>> From<http::Response<T>> for Response {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// A JSON object.
|
||||||
pub struct Json<T> {
|
pub struct Json<T> {
|
||||||
concat: Concat2<Decoder>,
|
concat: Concat2<Decoder>,
|
||||||
_marker: PhantomData<T>,
|
_marker: PhantomData<T>,
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ use futures::future::{self, Either};
|
|||||||
use futures::sync::{mpsc, oneshot};
|
use futures::sync::{mpsc, oneshot};
|
||||||
|
|
||||||
use request::{Request, RequestBuilder};
|
use request::{Request, RequestBuilder};
|
||||||
use response::{self, Response};
|
use response::Response;
|
||||||
use {async_impl, header, Certificate, Identity, Method, IntoUrl, Proxy, RedirectPolicy, wait};
|
use {async_impl, header, Certificate, Identity, Method, IntoUrl, Proxy, RedirectPolicy, wait};
|
||||||
|
|
||||||
/// A `Client` to make Requests with.
|
/// A `Client` to make Requests with.
|
||||||
@@ -500,7 +500,7 @@ impl ClientHandle {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
res.map(|res| {
|
res.map(|res| {
|
||||||
response::new(res, self.timeout.0, KeepCoreThreadAlive(Some(self.inner.clone())))
|
Response::new(res, self.timeout.0, KeepCoreThreadAlive(Some(self.inner.clone())))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -515,9 +515,7 @@ impl Default for Timeout {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// pub(crate)
|
pub(crate) struct KeepCoreThreadAlive(Option<Arc<InnerClientHandle>>);
|
||||||
|
|
||||||
pub struct KeepCoreThreadAlive(Option<Arc<InnerClientHandle>>);
|
|
||||||
|
|
||||||
impl KeepCoreThreadAlive {
|
impl KeepCoreThreadAlive {
|
||||||
pub(crate) fn empty() -> KeepCoreThreadAlive {
|
pub(crate) fn empty() -> KeepCoreThreadAlive {
|
||||||
|
|||||||
@@ -13,16 +13,14 @@ use std::sync::Arc;
|
|||||||
|
|
||||||
use {proxy, Proxy};
|
use {proxy, Proxy};
|
||||||
|
|
||||||
// pub(crate)
|
pub(crate) struct Connector {
|
||||||
|
|
||||||
pub struct Connector {
|
|
||||||
https: HttpsConnector<HttpConnector>,
|
https: HttpsConnector<HttpConnector>,
|
||||||
proxies: Arc<Vec<Proxy>>,
|
proxies: Arc<Vec<Proxy>>,
|
||||||
tls: TlsConnector,
|
tls: TlsConnector,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Connector {
|
impl Connector {
|
||||||
pub fn new(threads: usize, tls: TlsConnector, proxies: Arc<Vec<Proxy>>) -> Connector {
|
pub(crate) fn new(threads: usize, tls: TlsConnector, proxies: Arc<Vec<Proxy>>) -> Connector {
|
||||||
let mut http = HttpConnector::new(threads);
|
let mut http = HttpConnector::new(threads);
|
||||||
http.enforce_http(false);
|
http.enforce_http(false);
|
||||||
let https = HttpsConnector::from((http, tls.clone()));
|
let https = HttpsConnector::from((http, tls.clone()));
|
||||||
@@ -81,9 +79,9 @@ impl Connect for Connector {
|
|||||||
type HttpStream = <HttpConnector as Connect>::Transport;
|
type HttpStream = <HttpConnector as Connect>::Transport;
|
||||||
type HttpsStream = MaybeHttpsStream<HttpStream>;
|
type HttpsStream = MaybeHttpsStream<HttpStream>;
|
||||||
|
|
||||||
pub type Connecting = Box<Future<Item=(Conn, Connected), Error=io::Error> + Send>;
|
pub(crate) type Connecting = Box<Future<Item=(Conn, Connected), Error=io::Error> + Send>;
|
||||||
|
|
||||||
pub enum Conn {
|
pub(crate) enum Conn {
|
||||||
Normal(HttpsStream),
|
Normal(HttpsStream),
|
||||||
Proxied(TlsStream<MaybeHttpsStream<HttpStream>>),
|
Proxied(TlsStream<MaybeHttpsStream<HttpStream>>),
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,8 +9,6 @@ pub trait IntoUrl: PolyfillTryInto {}
|
|||||||
|
|
||||||
impl<T: PolyfillTryInto> IntoUrl for T {}
|
impl<T: PolyfillTryInto> IntoUrl for T {}
|
||||||
|
|
||||||
// pub(crate)
|
|
||||||
|
|
||||||
pub trait PolyfillTryInto {
|
pub trait PolyfillTryInto {
|
||||||
// Besides parsing as a valid `Url`, the `Url` must be a valid
|
// Besides parsing as a valid `Url`, the `Url` must be a valid
|
||||||
// `http::Uri`, in that it makes sense to use in a network request.
|
// `http::Uri`, in that it makes sense to use in a network request.
|
||||||
|
|||||||
@@ -180,11 +180,9 @@ impl fmt::Debug for Custom {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// pub(crate)
|
|
||||||
|
|
||||||
/// A helper trait to allow testing `Proxy::intercept` without having to
|
/// A helper trait to allow testing `Proxy::intercept` without having to
|
||||||
/// construct `hyper::client::connect::Destination`s.
|
/// construct `hyper::client::connect::Destination`s.
|
||||||
trait Dst {
|
pub(crate) trait Dst {
|
||||||
fn scheme(&self) -> &str;
|
fn scheme(&self) -> &str;
|
||||||
fn host(&self) -> &str;
|
fn host(&self) -> &str;
|
||||||
fn port(&self) -> Option<u16>;
|
fn port(&self) -> Option<u16>;
|
||||||
@@ -205,7 +203,7 @@ impl Dst for Destination {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn intercept(proxy: &Proxy, uri: &Destination) -> Option<::http::Uri> {
|
pub(crate) fn intercept(proxy: &Proxy, uri: &Destination) -> Option<::http::Uri> {
|
||||||
proxy.intercept(uri)
|
proxy.intercept(uri)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,6 +30,21 @@ impl fmt::Debug for Response {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Response {
|
impl Response {
|
||||||
|
pub(crate) fn new(mut res: async_impl::Response, timeout: Option<Duration>, thread: KeepCoreThreadAlive) -> Response {
|
||||||
|
let body = mem::replace(res.body_mut(), async_impl::Decoder::empty());
|
||||||
|
let len = body.content_length();
|
||||||
|
let body = async_impl::ReadableChunks::new(WaitBody {
|
||||||
|
inner: wait::stream(body, timeout)
|
||||||
|
});
|
||||||
|
|
||||||
|
Response {
|
||||||
|
inner: res,
|
||||||
|
body: body,
|
||||||
|
content_length: len,
|
||||||
|
_thread_handle: thread,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Get the final `Url` of this `Response`.
|
/// Get the final `Url` of this `Response`.
|
||||||
///
|
///
|
||||||
/// # Example
|
/// # Example
|
||||||
@@ -320,26 +335,9 @@ impl Stream for WaitBody {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// pub(crate)
|
|
||||||
|
|
||||||
pub fn new(mut res: async_impl::Response, timeout: Option<Duration>, thread: KeepCoreThreadAlive) -> Response {
|
|
||||||
let body = mem::replace(res.body_mut(), async_impl::Decoder::empty());
|
|
||||||
let len = body.content_length();
|
|
||||||
let body = async_impl::ReadableChunks::new(WaitBody {
|
|
||||||
inner: wait::stream(body, timeout)
|
|
||||||
});
|
|
||||||
|
|
||||||
Response {
|
|
||||||
inner: res,
|
|
||||||
body: body,
|
|
||||||
content_length: len,
|
|
||||||
_thread_handle: thread,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<T: Into<async_impl::body::Body>> From<http::Response<T>> for Response {
|
impl<T: Into<async_impl::body::Body>> From<http::Response<T>> for Response {
|
||||||
fn from(r: http::Response<T>) -> Response {
|
fn from(r: http::Response<T>) -> Response {
|
||||||
let response = async_impl::Response::from(r);
|
let response = async_impl::Response::from(r);
|
||||||
new(response, None, KeepCoreThreadAlive::empty())
|
Response::new(response, None, KeepCoreThreadAlive::empty())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -113,12 +113,10 @@ impl fmt::Debug for Identity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// pub(crate)
|
pub(crate) fn cert(cert: Certificate) -> native_tls::Certificate {
|
||||||
|
|
||||||
pub fn cert(cert: Certificate) -> native_tls::Certificate {
|
|
||||||
cert.0
|
cert.0
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn pkcs12(identity: Identity) -> native_tls::Identity {
|
pub(crate) fn pkcs12(identity: Identity) -> native_tls::Identity {
|
||||||
identity.0
|
identity.0
|
||||||
}
|
}
|
||||||
|
|||||||
11
src/wait.rs
11
src/wait.rs
@@ -5,10 +5,7 @@ use std::time::{Duration, Instant};
|
|||||||
use futures::{Async, Future, Stream};
|
use futures::{Async, Future, Stream};
|
||||||
use futures::executor::{self, Notify};
|
use futures::executor::{self, Notify};
|
||||||
|
|
||||||
// pub(crate)
|
pub(crate) fn timeout<F>(fut: F, timeout: Option<Duration>) -> Result<F::Item, Waited<F::Error>>
|
||||||
|
|
||||||
|
|
||||||
pub fn timeout<F>(fut: F, timeout: Option<Duration>) -> Result<F::Item, Waited<F::Error>>
|
|
||||||
where F: Future {
|
where F: Future {
|
||||||
if let Some(dur) = timeout {
|
if let Some(dur) = timeout {
|
||||||
let start = Instant::now();
|
let start = Instant::now();
|
||||||
@@ -35,7 +32,7 @@ where F: Future {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn stream<S>(stream: S, timeout: Option<Duration>) -> WaitStream<S>
|
pub(crate) fn stream<S>(stream: S, timeout: Option<Duration>) -> WaitStream<S>
|
||||||
where S: Stream {
|
where S: Stream {
|
||||||
WaitStream {
|
WaitStream {
|
||||||
stream: executor::spawn(stream),
|
stream: executor::spawn(stream),
|
||||||
@@ -44,7 +41,7 @@ where S: Stream {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum Waited<E> {
|
pub(crate) enum Waited<E> {
|
||||||
TimedOut,
|
TimedOut,
|
||||||
Err(E),
|
Err(E),
|
||||||
}
|
}
|
||||||
@@ -55,7 +52,7 @@ impl<E> From<E> for Waited<E> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct WaitStream<S> {
|
pub(crate) struct WaitStream<S> {
|
||||||
stream: executor::Spawn<S>,
|
stream: executor::Spawn<S>,
|
||||||
timeout: Option<Duration>,
|
timeout: Option<Duration>,
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user