diff --git a/src/async_impl/body.rs b/src/async_impl/body.rs index a3495af..482f503 100644 --- a/src/async_impl/body.rs +++ b/src/async_impl/body.rs @@ -146,38 +146,36 @@ impl fmt::Debug for Chunk { } } -// pub(crate) - #[inline] -pub fn wrap(body: ::hyper::Body) -> Body { +pub(crate) fn wrap(body: ::hyper::Body) -> Body { Body { inner: Inner::Hyper(body), } } #[inline] -pub fn empty() -> Body { +pub(crate) fn empty() -> Body { Body { inner: Inner::Hyper(::hyper::Body::empty()), } } #[inline] -pub fn chunk(chunk: Bytes) -> Chunk { +pub(crate) fn chunk(chunk: Bytes) -> Chunk { Chunk { inner: ::hyper::Chunk::from(chunk) } } #[inline] -pub fn reusable(chunk: Bytes) -> Body { +pub(crate) fn reusable(chunk: Bytes) -> Body { Body { inner: Inner::Reusable(chunk), } } #[inline] -pub fn into_hyper(body: Body) -> (Option, ::hyper::Body) { +pub(crate) fn into_hyper(body: Body) -> (Option, ::hyper::Body) { match body.inner { Inner::Reusable(chunk) => (Some(chunk.clone()), chunk.into()), Inner::Hyper(b) => (None, b), diff --git a/src/async_impl/decoder.rs b/src/async_impl/decoder.rs index 9b704fc..43d83fb 100644 --- a/src/async_impl/decoder.rs +++ b/src/async_impl/decoder.rs @@ -304,7 +304,7 @@ impl Read for Peeked { impl ReadableChunks { #[inline] - pub fn new(stream: S) -> Self { + pub(crate) fn new(stream: S) -> Self { ReadableChunks { state: ReadState::NotReady, stream: stream, @@ -387,15 +387,13 @@ impl ReadableChunks } } -// pub(crate) - /// Constructs a Decoder from a hyper request. /// /// A decoder is just a wrapper around the hyper request that knows /// how to decode the content body of the request. /// /// 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 { return Decoder::plain_text(body); } diff --git a/src/async_impl/response.rs b/src/async_impl/response.rs index 7dd11fb..45f3e4e 100644 --- a/src/async_impl/response.rs +++ b/src/async_impl/response.rs @@ -164,6 +164,7 @@ impl> From> for Response { } } +/// A JSON object. pub struct Json { concat: Concat2, _marker: PhantomData, diff --git a/src/client.rs b/src/client.rs index f59f777..01f7027 100644 --- a/src/client.rs +++ b/src/client.rs @@ -8,7 +8,7 @@ use futures::future::{self, Either}; use futures::sync::{mpsc, oneshot}; use request::{Request, RequestBuilder}; -use response::{self, Response}; +use response::Response; use {async_impl, header, Certificate, Identity, Method, IntoUrl, Proxy, RedirectPolicy, wait}; /// A `Client` to make Requests with. @@ -500,7 +500,7 @@ impl ClientHandle { } }; 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 struct KeepCoreThreadAlive(Option>); +pub(crate) struct KeepCoreThreadAlive(Option>); impl KeepCoreThreadAlive { pub(crate) fn empty() -> KeepCoreThreadAlive { diff --git a/src/connect.rs b/src/connect.rs index f41eb67..de9f4b0 100644 --- a/src/connect.rs +++ b/src/connect.rs @@ -13,16 +13,14 @@ use std::sync::Arc; use {proxy, Proxy}; -// pub(crate) - -pub struct Connector { +pub(crate) struct Connector { https: HttpsConnector, proxies: Arc>, tls: TlsConnector, } impl Connector { - pub fn new(threads: usize, tls: TlsConnector, proxies: Arc>) -> Connector { + pub(crate) fn new(threads: usize, tls: TlsConnector, proxies: Arc>) -> Connector { let mut http = HttpConnector::new(threads); http.enforce_http(false); let https = HttpsConnector::from((http, tls.clone())); @@ -81,9 +79,9 @@ impl Connect for Connector { type HttpStream = ::Transport; type HttpsStream = MaybeHttpsStream; -pub type Connecting = Box + Send>; +pub(crate) type Connecting = Box + Send>; -pub enum Conn { +pub(crate) enum Conn { Normal(HttpsStream), Proxied(TlsStream>), } diff --git a/src/into_url.rs b/src/into_url.rs index 65c2cf7..bc7ab2c 100644 --- a/src/into_url.rs +++ b/src/into_url.rs @@ -9,8 +9,6 @@ pub trait IntoUrl: PolyfillTryInto {} impl IntoUrl for T {} -// pub(crate) - pub trait PolyfillTryInto { // 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. diff --git a/src/proxy.rs b/src/proxy.rs index 947efb8..37c722c 100644 --- a/src/proxy.rs +++ b/src/proxy.rs @@ -180,11 +180,9 @@ impl fmt::Debug for Custom { } } -// pub(crate) - /// A helper trait to allow testing `Proxy::intercept` without having to /// construct `hyper::client::connect::Destination`s. -trait Dst { +pub(crate) trait Dst { fn scheme(&self) -> &str; fn host(&self) -> &str; fn port(&self) -> Option; @@ -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) } diff --git a/src/response.rs b/src/response.rs index bfe5c8d..0454963 100644 --- a/src/response.rs +++ b/src/response.rs @@ -30,6 +30,21 @@ impl fmt::Debug for Response { } impl Response { + pub(crate) fn new(mut res: async_impl::Response, timeout: Option, 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`. /// /// # Example @@ -320,26 +335,9 @@ impl Stream for WaitBody { } } -// pub(crate) - -pub fn new(mut res: async_impl::Response, timeout: Option, 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> From> for Response { fn from(r: http::Response) -> Response { let response = async_impl::Response::from(r); - new(response, None, KeepCoreThreadAlive::empty()) + Response::new(response, None, KeepCoreThreadAlive::empty()) } } diff --git a/src/tls.rs b/src/tls.rs index fe3570c..8a631bb 100644 --- a/src/tls.rs +++ b/src/tls.rs @@ -113,12 +113,10 @@ impl fmt::Debug for Identity { } } -// pub(crate) - -pub fn cert(cert: Certificate) -> native_tls::Certificate { +pub(crate) fn cert(cert: Certificate) -> native_tls::Certificate { cert.0 } -pub fn pkcs12(identity: Identity) -> native_tls::Identity { +pub(crate) fn pkcs12(identity: Identity) -> native_tls::Identity { identity.0 } diff --git a/src/wait.rs b/src/wait.rs index 6360088..d6c975e 100644 --- a/src/wait.rs +++ b/src/wait.rs @@ -5,10 +5,7 @@ use std::time::{Duration, Instant}; use futures::{Async, Future, Stream}; use futures::executor::{self, Notify}; -// pub(crate) - - -pub fn timeout(fut: F, timeout: Option) -> Result> +pub(crate) fn timeout(fut: F, timeout: Option) -> Result> where F: Future { if let Some(dur) = timeout { let start = Instant::now(); @@ -35,7 +32,7 @@ where F: Future { } } -pub fn stream(stream: S, timeout: Option) -> WaitStream +pub(crate) fn stream(stream: S, timeout: Option) -> WaitStream where S: Stream { WaitStream { stream: executor::spawn(stream), @@ -44,7 +41,7 @@ where S: Stream { } #[derive(Debug)] -pub enum Waited { +pub(crate) enum Waited { TimedOut, Err(E), } @@ -55,7 +52,7 @@ impl From for Waited { } } -pub struct WaitStream { +pub(crate) struct WaitStream { stream: executor::Spawn, timeout: Option, }