diff --git a/README.md b/README.md index 18a4d73..dabf647 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,7 @@ Next, add this to your crate: ```rust extern crate h2; -use h2::server::Server; +use h2::server::Connection; fn main() { // ... diff --git a/examples/akamai.rs b/examples/akamai.rs index cb9645c..1c391ee 100644 --- a/examples/akamai.rs +++ b/examples/akamai.rs @@ -8,7 +8,7 @@ extern crate tokio_core; extern crate tokio_rustls; extern crate webpki_roots; -use h2::client::Client; +use h2::client; use futures::*; use http::{Method, Request}; @@ -64,7 +64,7 @@ pub fn main() { let tls = io_dump::Dump::to_stdout(tls); println!("Starting client handshake"); - Client::handshake(tls) + client::handshake(tls) }) .then(|res| { let (mut client, h2) = res.unwrap(); diff --git a/examples/client.rs b/examples/client.rs index 1ae8053..547fe66 100644 --- a/examples/client.rs +++ b/examples/client.rs @@ -5,7 +5,7 @@ extern crate http; extern crate io_dump; extern crate tokio_core; -use h2::client::{Client}; +use h2::client; use h2::RecvStream; use futures::*; @@ -55,7 +55,7 @@ pub fn main() { let tcp = tcp.then(|res| { let tcp = io_dump::Dump::to_stdout(res.unwrap()); - Client::handshake(tcp) + client::handshake(tcp) }).then(|res| { let (mut client, h2) = res.unwrap(); diff --git a/examples/server-tr.rs b/examples/server-tr.rs index ec53324..f94d3cc 100644 --- a/examples/server-tr.rs +++ b/examples/server-tr.rs @@ -5,7 +5,7 @@ extern crate h2; extern crate http; extern crate tokio_core; -use h2::server::Server; +use h2::server; use bytes::*; use futures::*; @@ -28,7 +28,7 @@ pub fn main() { // let socket = io_dump::Dump::to_stdout(socket); - let connection = Server::handshake(socket) + let connection = server::handshake(socket) .and_then(|conn| { println!("H2 connection bound"); diff --git a/examples/server.rs b/examples/server.rs index 5cdc3d0..7919854 100644 --- a/examples/server.rs +++ b/examples/server.rs @@ -5,7 +5,7 @@ extern crate h2; extern crate http; extern crate tokio_core; -use h2::server::Server; +use h2::server; use bytes::*; use futures::*; @@ -27,7 +27,7 @@ pub fn main() { let server = listener.incoming().for_each(move |(socket, _)| { // let socket = io_dump::Dump::to_stdout(socket); - let connection = Server::handshake(socket) + let connection = server::handshake(socket) .and_then(|conn| { println!("H2 connection bound"); diff --git a/src/client.rs b/src/client.rs index 6d8f649..660d08e 100644 --- a/src/client.rs +++ b/src/client.rs @@ -23,7 +23,7 @@ pub struct Handshake { } /// Marker type indicating a client peer -pub struct Client { +pub struct SendRequest { inner: proto::Streams, pending: Option, } @@ -43,7 +43,7 @@ pub struct ResponseFuture { inner: proto::OpaqueStreamRef, } -/// Build a Client. +/// Build a client. #[derive(Clone, Debug)] pub struct Builder { /// Time to keep locally reset streams around before reaping. @@ -63,54 +63,13 @@ pub struct Builder { #[derive(Debug)] pub(crate) struct Peer; -// ===== impl Client ===== +// ===== impl SendRequest ===== -impl Client { - /// Bind an H2 client connection. - /// - /// Returns a future which resolves to the connection value once the H2 - /// handshake has been completed. - /// - /// It's important to note that this does not **flush** the outbound - /// settings to the wire. - pub fn handshake(io: T) -> Handshake - where - T: AsyncRead + AsyncWrite, - { - Builder::default().handshake(io) - } -} - -impl Client { - /// Creates a Client Builder to customize a Client before binding. - pub fn builder() -> Builder { - Builder::default() - } -} - -impl Client +impl SendRequest where B: IntoBuf, B::Buf: 'static, { - fn handshake2(io: T, builder: Builder) -> Handshake - where - T: AsyncRead + AsyncWrite, - { - use tokio_io::io; - - debug!("binding client connection"); - - let msg: &'static [u8] = b"PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n"; - let handshake = io::write_all(io, msg); - - Handshake { - builder, - inner: handshake, - _marker: PhantomData, - } - } - /// Returns `Ready` when the connection can initialize a new HTTP 2.0 /// stream. pub fn poll_ready(&mut self) -> Poll<(), ::Error> { @@ -144,21 +103,21 @@ where } } -impl fmt::Debug for Client +impl fmt::Debug for SendRequest where B: IntoBuf, { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - fmt.debug_struct("Client").finish() + fmt.debug_struct("SendRequest").finish() } } -impl Clone for Client +impl Clone for SendRequest where B: IntoBuf, { fn clone(&self) -> Self { - Client { + SendRequest { inner: self.inner.clone(), pending: None, } @@ -166,7 +125,7 @@ where } #[cfg(feature = "unstable")] -impl Client +impl SendRequest where B: IntoBuf, { @@ -191,6 +150,16 @@ where // ===== impl Builder ===== impl Builder { + /// Creates a `Connection` Builder to customize a `Connection` before binding. + pub fn new() -> Builder { + Builder { + reset_stream_duration: Duration::from_secs(proto::DEFAULT_RESET_STREAM_SECS), + reset_stream_max: proto::DEFAULT_RESET_STREAM_MAX, + settings: Default::default(), + stream_id: 1.into(), + } + } + /// Set the initial window size of the remote peer. pub fn initial_window_size(&mut self, size: u32) -> &mut Self { self.settings.set_initial_window_size(Some(size)); @@ -265,29 +234,51 @@ impl Builder { B: IntoBuf, B::Buf: 'static, { - Client::handshake2(io, self.clone()) + Connection::handshake2(io, self.clone()) } } impl Default for Builder { fn default() -> Builder { - Builder { - reset_stream_duration: Duration::from_secs(proto::DEFAULT_RESET_STREAM_SECS), - reset_stream_max: proto::DEFAULT_RESET_STREAM_MAX, - settings: Default::default(), - stream_id: 1.into(), - } + Builder::new() } } -// ===== impl Connection ===== +/// Bind an H2 client connection. +/// +/// Returns a future which resolves to the connection value once the H2 +/// handshake has been completed. +/// +/// It's important to note that this does not **flush** the outbound +/// settings to the wire. +pub fn handshake(io: T) -> Handshake +where T: AsyncRead + AsyncWrite, +{ + Builder::new().handshake(io) +} +// ===== impl Connection ===== impl Connection where T: AsyncRead + AsyncWrite, B: IntoBuf, { + fn handshake2(io: T, builder: Builder) -> Handshake { + use tokio_io::io; + + debug!("binding client connection"); + + let msg: &'static [u8] = b"PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n"; + let handshake = io::write_all(io, msg); + + Handshake { + builder, + inner: handshake, + _marker: PhantomData, + } + } + /// Sets the target window size for the whole connection. /// /// Default in HTTP2 is 65_535. @@ -330,7 +321,7 @@ where B: IntoBuf, B::Buf: 'static, { - type Item = (Client, Connection); + type Item = (SendRequest, Connection); type Error = ::Error; fn poll(&mut self) -> Poll { @@ -359,14 +350,14 @@ where reset_stream_max: self.builder.reset_stream_max, settings: self.builder.settings.clone(), }); - let client = Client { + let send_request = SendRequest { inner: connection.streams().clone(), pending: None, }; - let conn = Connection { + let connection = Connection { inner: connection, }; - Ok(Async::Ready((client, conn))) + Ok(Async::Ready((send_request, connection))) } } diff --git a/src/server.rs b/src/server.rs index 8893132..74bb9a9 100644 --- a/src/server.rs +++ b/src/server.rs @@ -7,44 +7,47 @@ //! HTTP/2.0 handshake. See [here](../index.html#handshake) for more details. //! //! Once a connection is obtained and primed (ALPN negotiation, HTTP/1.1 -//! upgrade, etc...), the connection handle is passed to [`Server::handshake`], -//! which will begin the [HTTP/2.0 handshake]. This returns a future that will -//! complete once the handshake is complete and HTTP/2.0 streams may be -//! received. +//! upgrade, etc...), the connection handle is passed to +//! [`Connection::handshake`], which will begin the [HTTP/2.0 handshake]. This +//! returns a future that will complete once the handshake is complete and +//! HTTP/2.0 streams may be received. //! -//! [`Server::handshake`] will use a default configuration. There are a number -//! of configuration values that can be set by using a [`Builder`] instead. +//! [`Connection::handshake`] will use a default configuration. There are a +//! number of configuration values that can be set by using a [`Builder`] +//! instead. //! //! # Inbound streams //! -//! The [`Server`] instance is used to accept inbound HTTP/2.0 streams. It does -//! this by implementing [`futures::Stream`]. When a new stream is received, a -//! call to [`Server::poll`] will return `(request, response)`. The `request` -//! handle (of type [`http::Request`]) contains the HTTP request -//! head as well as provides a way to receive the inbound data stream and the -//! trailers. The `response` handle (of type [`SendStream`]) allows responding -//! to the request, stream the response payload, send trailers, and send push -//! promises. +//! The [`Connection`] instance is used to accept inbound HTTP/2.0 streams. It +//! does this by implementing [`futures::Stream`]. When a new stream is +//! received, a call to [`Connection::poll`] will return `(request, response)`. +//! The `request` handle (of type [`http::Request`]) contains the +//! HTTP request head as well as provides a way to receive the inbound data +//! stream and the trailers. The `response` handle (of type [`SendStream`]) +//! allows responding to the request, stream the response payload, send +//! trailers, and send push promises. //! //! The send ([`SendStream`]) and receive ([`RecvStream`]) halves of the stream //! can be operated independently. //! //! # Managing the connection //! -//! The [`Server`] instance is used to manage the connection state. The caller -//! is required to call either [`Server::poll`] or [`Server::poll_close`] in -//! order to advance the connection state. Simply operating on [`SendStream`] or -//! [`RecvStream`] will have no effect unless the connection state is advanced. +//! The [`Connection`] instance is used to manage the connection state. The +//! caller is required to call either [`Connection::poll`] or +//! [`Connection::poll_close`] in order to advance the connection state. Simply +//! operating on [`SendStream`] or [`RecvStream`] will have no effect unless the +//! connection state is advanced. //! -//! It is not required to call **both** [`Server::poll`] and -//! [`Server::poll_close`]. If the caller is ready to accept a new stream, then -//! only [`Server::poll`] should be called. When the caller **does not** want to -//! accept a new stream, [`Server::poll_close`] should be called. +//! It is not required to call **both** [`Connection::poll`] and +//! [`Connection::poll_close`]. If the caller is ready to accept a new stream, +//! then only [`Connection::poll`] should be called. When the caller **does +//! not** want to accept a new stream, [`Connection::poll_close`] should be +//! called. //! -//! The [`Server`] instance should only be dropped once [`Server::poll_close`] -//! returns `Ready`. Once [`Server::poll`] returns `Ready(None)`, there will no -//! longer be any more inbound streams. At this point, only -//! [`Server::poll_close`] should be called. +//! The [`Connection`] instance should only be dropped once +//! [`Connection::poll_close`] returns `Ready`. Once [`Connection::poll`] +//! returns `Ready(None)`, there will no longer be any more inbound streams. At +//! this point, only [`Connection::poll_close`] should be called. //! //! # Shutting down the server //! @@ -65,7 +68,7 @@ //! //! use futures::{Future, Stream}; //! # use futures::future::ok; -//! use h2::server::Server; +//! use h2::server; //! use http::{Response, StatusCode}; //! use tokio_core::reactor; //! use tokio_core::net::TcpListener; @@ -83,7 +86,7 @@ //! // Spawn a new task to process each connection. //! handle.spawn({ //! // Start the HTTP/2.0 connection handshake -//! Server::handshake(socket) +//! server::handshake(socket) //! .and_then(|h2| { //! // Accept all inbound HTTP/2.0 streams sent over the //! // connection. @@ -114,12 +117,12 @@ //! ``` //! //! [prior knowledge]: http://httpwg.org/specs/rfc7540.html#known-http -//! [`Server::handshake`]: struct.Server.html#method.handshake +//! [`Connection::handshake`]: struct.Connection.html#method.handshake //! [HTTP/2.0 handshake]: http://httpwg.org/specs/rfc7540.html#ConnectionHeader //! [`Builder`]: struct.Builder.html -//! [`Server`]: struct.Server.html -//! [`Server::poll`]: struct.Server.html#method.poll -//! [`Server::poll_close`]: struct.Server.html#method.poll_close +//! [`Connection`]: struct.Connection.html +//! [`Connection::poll`]: struct.Connection.html#method.poll +//! [`Connection::poll_close`]: struct.Connection.html#method.poll_close //! [`futures::Stream`]: https://docs.rs/futures/0.1/futures/stream/trait.Stream.html //! [`http::Request`]: ../struct.RecvStream.html //! [`SendStream`]: ../struct.SendStream.html @@ -127,7 +130,7 @@ use {SendStream, RecvStream, ReleaseCapacity}; use codec::{Codec, RecvError}; use frame::{self, Reason, Settings, StreamId}; -use proto::{self, Config, Connection, Prioritized}; +use proto::{self, Config, Prioritized}; use bytes::{Buf, Bytes, IntoBuf}; use futures::{self, Async, Future, Poll}; @@ -138,7 +141,7 @@ use std::time::Duration; /// In progress HTTP/2.0 connection handshake future. /// -/// This type implements `Future`, yielding a `Server` instance once the +/// This type implements `Future`, yielding a `Connection` instance once the /// handshake has completed. /// /// The handshake is completed once the connection preface is fully received @@ -160,21 +163,21 @@ pub struct Handshake { /// Accepts inbound HTTP/2.0 streams on a connection. /// -/// A `Server` is backed by an I/O resource (usually a TCP socket) and +/// A `Connection` is backed by an I/O resource (usually a TCP socket) and /// implements the HTTP/2.0 server logic for that connection. It is responsible /// for receiving inbound streams initiated by the client as well as driving the /// internal state forward. /// -/// `Server` values are created by calling [`handshake`]. Once a `Server` value -/// is obtained, the caller must call [`poll`] or [`poll_close`] in order to -/// drive the internal connection state forward. +/// `Connection` values are created by calling [`handshake`]. Once a +/// `Connection` value is obtained, the caller must call [`poll`] or +/// [`poll_close`] in order to drive the internal connection state forward. /// /// See [module level] documentation for more details /// /// [module level]: index.html -/// [`handshake`]: struct.Server.html#method.handshake -/// [`poll`]: struct.Server.html#method.poll -/// [`poll_close`]: struct.Server.html#method.poll_close +/// [`handshake`]: struct.Connection.html#method.handshake +/// [`poll`]: struct.Connection.html#method.poll +/// [`poll_close`]: struct.Connection.html#method.poll_close /// /// # Examples /// @@ -184,10 +187,11 @@ pub struct Handshake { /// # extern crate tokio_io; /// # use futures::{Future, Stream}; /// # use tokio_io::*; +/// # use h2::server; /// # use h2::server::*; /// # /// # fn doc(my_io: T) { -/// Server::handshake(my_io) +/// server::handshake(my_io) /// .and_then(|server| { /// server.for_each(|(request, respond)| { /// // Process the request and send the response back to the client @@ -201,24 +205,24 @@ pub struct Handshake { /// # pub fn main() {} /// ``` #[must_use = "streams do nothing unless polled"] -pub struct Server { - connection: Connection, +pub struct Connection { + connection: proto::Connection, } -/// Server factory, which can be used in order to configure the properties of -/// the HTTP/2.0 server before it is created. +/// Client connection factory, which can be used in order to configure the +/// properties of the HTTP/2.0 server before it is created. /// /// Methods can be changed on it in order to configure it. /// /// The server is constructed by calling [`handshake`] and passing the I/O /// handle that will back the HTTP/2.0 server. /// -/// New instances of `Builder` are obtained via [`Server::builder`]. +/// New instances of `Builder` are obtained via [`Builder::new`]. /// /// See function level documentation for details on the various server /// configuration settings. /// -/// [`Server::builder`]: struct.Server.html#method.builder +/// [`Builder::new`]: struct.Builder.html#method.new /// [`handshake`]: struct.Builder.html#method.handshake /// /// # Examples @@ -234,7 +238,7 @@ pub struct Server { /// # { /// // `server_fut` is a future representing the completion of the HTTP/2.0 /// // handshake. -/// let server_fut = Server::builder() +/// let server_fut = Builder::new() /// .initial_window_size(1_000_000) /// .max_concurrent_streams(1000) /// .handshake(my_io); @@ -255,32 +259,32 @@ pub struct Builder { settings: Settings, } -/// Respond to a client request. +/// Send a response back to the client /// -/// A `Respond` instance is provided when receiving a request and is used to -/// send the associated response back to the client. It is also used to +/// A `SendResponse` instance is provided when receiving a request and is used +/// to send the associated response back to the client. It is also used to /// explicitly reset the stream with a custom reason. /// /// It will also be used to initiate push promises linked with the associated /// stream. This is [not yet /// implemented](https://github.com/carllerche/h2/issues/185). /// -/// If the `Respond` instance is dropped without sending a response, then the -/// HTTP/2.0 stream will be reset. +/// If the `SendResponse` instance is dropped without sending a response, then +/// the HTTP/2.0 stream will be reset. /// /// See [module] level docs for more details. /// /// [module]: index.html #[derive(Debug)] -pub struct Respond { +pub struct SendResponse { inner: proto::StreamRef, } /// Stages of an in-progress handshake. enum Handshaking { - /// State 1. Server is flushing pending SETTINGS frame. + /// State 1. Connection is flushing pending SETTINGS frame. Flushing(Flush>), - /// State 2. Server is waiting for the client preface. + /// State 2. Connection is waiting for the client preface. ReadingPreface(ReadPreface>), /// Dummy state for `mem::replace`. Empty, @@ -302,85 +306,50 @@ pub(crate) struct Peer; const PREFACE: [u8; 24] = *b"PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n"; -// ===== impl Server ===== - -impl Server -where - T: AsyncRead + AsyncWrite, +/// Create a new configured HTTP/2.0 server with default configuration +/// values backed by `io`. +/// +/// It is expected that `io` already be in an appropriate state to commence +/// the [HTTP/2.0 handshake]. See [Handshake] for more details. +/// +/// Returns a future which resolves to the [`Connection`] instance once the +/// HTTP/2.0 handshake has been completed. The returned [`Connection`] +/// instance will be using default configuration values. Use [`Builder`] to +/// customize the configuration values used by a [`Connection`] instance. +/// +/// [HTTP/2.0 handshake]: http://httpwg.org/specs/rfc7540.html#ConnectionHeader +/// [Handshake]: ../index.html#handshake +/// [`Connection`]: struct.Connection.html +/// +/// # Examples +/// +/// ``` +/// # extern crate h2; +/// # extern crate tokio_io; +/// # use tokio_io::*; +/// # use h2::server; +/// # use h2::server::*; +/// # +/// # fn doc(my_io: T) +/// # -> Handshake +/// # { +/// // `server_fut` is a future representing the completion of the HTTP/2.0 +/// // handshake. +/// let handshake_fut = server::handshake(my_io); +/// # handshake_fut +/// # } +/// # +/// # pub fn main() {} +/// ``` +pub fn handshake(io: T) -> Handshake +where T: AsyncRead + AsyncWrite, { - /// Create a new configured HTTP/2.0 server with default configuration - /// values backed by `io`. - /// - /// It is expected that `io` already be in an appropriate state to commence - /// the [HTTP/2.0 handshake]. See [Handshake] for more details. - /// - /// Returns a future which resolves to the [`Server`] instance once the - /// HTTP/2.0 handshake has been completed. The returned [`Server`] instance - /// will be using default configuration values. Use [`Builder`] to customize - /// the configuration values used by a [`Server`] instance. - /// - /// [HTTP/2.0 handshake]: http://httpwg.org/specs/rfc7540.html#ConnectionHeader - /// [Handshake]: ../index.html#handshake - /// [`Server`]: struct.Server.html - /// - /// # Examples - /// - /// ``` - /// # extern crate h2; - /// # extern crate tokio_io; - /// # use tokio_io::*; - /// # use h2::server::*; - /// # - /// # fn doc(my_io: T) - /// # -> Handshake - /// # { - /// // `server_fut` is a future representing the completion of the HTTP/2.0 - /// // handshake. - /// let handshake_fut = Server::handshake(my_io); - /// # handshake_fut - /// # } - /// # - /// # pub fn main() {} - /// ``` - pub fn handshake(io: T) -> Handshake { - Server::builder().handshake(io) - } + Builder::new().handshake(io) } -impl Server<(), Bytes> { - /// Return a new `Server` builder instance initialized with default - /// configuration values. - /// - /// Configuration methods can be chained on the return value. - /// - /// # Examples - /// - /// ``` - /// # extern crate h2; - /// # extern crate tokio_io; - /// # use tokio_io::*; - /// # use h2::server::*; - /// # - /// # fn doc(my_io: T) - /// # -> Handshake - /// # { - /// // `server_fut` is a future representing the completion of the HTTP/2.0 - /// // handshake. - /// let server_fut = Server::builder() - /// .initial_window_size(1_000_000) - /// .max_concurrent_streams(1000) - /// .handshake(my_io); - /// # server_fut - /// # } - /// # - /// # pub fn main() {} - /// ``` - pub fn builder() -> Builder { - Builder::default() - } -} +// ===== impl Connection ===== -impl Server +impl Connection where T: AsyncRead + AsyncWrite, B: IntoBuf, @@ -437,7 +406,7 @@ where /// /// See [here](index.html#managing-the-connection) for more details. /// - /// [`poll`]: struct.Server.html#method.poll + /// [`poll`]: struct.Connection.html#method.poll /// [`RecvStream`]: ../struct.RecvStream.html /// [`SendStream`]: ../struct.SendStream.html pub fn poll_close(&mut self) -> Poll<(), ::Error> { @@ -445,13 +414,13 @@ where } } -impl futures::Stream for Server +impl futures::Stream for Connection where T: AsyncRead + AsyncWrite, B: IntoBuf, B::Buf: 'static, { - type Item = (Request, Respond); + type Item = (Request, SendResponse); type Error = ::Error; fn poll(&mut self) -> Poll, ::Error> { @@ -472,7 +441,7 @@ where let body = RecvStream::new(ReleaseCapacity::new(inner.clone_to_opaque())); let request = Request::from_parts(head, body); - let respond = Respond { inner }; + let respond = SendResponse { inner }; return Ok(Some((request, respond)).into()); } @@ -481,14 +450,14 @@ where } } -impl fmt::Debug for Server +impl fmt::Debug for Connection where T: fmt::Debug, B: fmt::Debug + IntoBuf, B::Buf: fmt::Debug, { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - fmt.debug_struct("Server") + fmt.debug_struct("Connection") .field("connection", &self.connection) .finish() } @@ -497,6 +466,41 @@ where // ===== impl Builder ===== impl Builder { + /// Return a new client builder instance initialized with default + /// configuration values. + /// + /// Configuration methods can be chained on the return value. + /// + /// # Examples + /// + /// ``` + /// # extern crate h2; + /// # extern crate tokio_io; + /// # use tokio_io::*; + /// # use h2::server::*; + /// # + /// # fn doc(my_io: T) + /// # -> Handshake + /// # { + /// // `server_fut` is a future representing the completion of the HTTP/2.0 + /// // handshake. + /// let server_fut = Builder::new() + /// .initial_window_size(1_000_000) + /// .max_concurrent_streams(1000) + /// .handshake(my_io); + /// # server_fut + /// # } + /// # + /// # pub fn main() {} + /// ``` + pub fn new() -> Builder { + Builder { + reset_stream_duration: Duration::from_secs(proto::DEFAULT_RESET_STREAM_SECS), + reset_stream_max: proto::DEFAULT_RESET_STREAM_MAX, + settings: Settings::default(), + } + } + /// Indicates the initial window size (in octets) for stream-level /// flow control for received data. /// @@ -520,7 +524,7 @@ impl Builder { /// # { /// // `server_fut` is a future representing the completion of the HTTP/2.0 /// // handshake. - /// let server_fut = Server::builder() + /// let server_fut = Builder::new() /// .initial_window_size(1_000_000) /// .handshake(my_io); /// # server_fut @@ -555,7 +559,7 @@ impl Builder { /// # { /// // `server_fut` is a future representing the completion of the HTTP/2.0 /// // handshake. - /// let server_fut = Server::builder() + /// let server_fut = Builder::new() /// .max_frame_size(1_000_000) /// .handshake(my_io); /// # server_fut @@ -610,7 +614,7 @@ impl Builder { /// # { /// // `server_fut` is a future representing the completion of the HTTP/2.0 /// // handshake. - /// let server_fut = Server::builder() + /// let server_fut = Builder::new() /// .max_concurrent_streams(1000) /// .handshake(my_io); /// # server_fut @@ -626,9 +630,10 @@ impl Builder { /// Set the maximum number of concurrent locally reset streams. /// /// When a stream is explicitly reset by either calling - /// [`Respond::send_reset`] or by dropping a [`Respond`] instance before - /// completing te stream, the HTTP/2.0 specification requires that any - /// further frames received for that stream must be ignored for "some time". + /// [`SendResponse::send_reset`] or by dropping a [`SendResponse`] instance + /// before completing te stream, the HTTP/2.0 specification requires that + /// any further frames received for that stream must be ignored for "some + /// time". /// /// In order to satisfy the specification, internal state must be maintained /// to implement the behavior. This state grows linearly with the number of @@ -657,7 +662,7 @@ impl Builder { /// # { /// // `server_fut` is a future representing the completion of the HTTP/2.0 /// // handshake. - /// let server_fut = Server::builder() + /// let server_fut = Builder::new() /// .max_concurrent_reset_streams(1000) /// .handshake(my_io); /// # server_fut @@ -673,9 +678,10 @@ impl Builder { /// Set the maximum number of concurrent locally reset streams. /// /// When a stream is explicitly reset by either calling - /// [`Respond::send_reset`] or by dropping a [`Respond`] instance before - /// completing te stream, the HTTP/2.0 specification requires that any - /// further frames received for that stream must be ignored for "some time". + /// [`SendResponse::send_reset`] or by dropping a [`SendResponse`] instance + /// before completing te stream, the HTTP/2.0 specification requires that + /// any further frames received for that stream must be ignored for "some + /// time". /// /// In order to satisfy the specification, internal state must be maintained /// to implement the behavior. This state grows linearly with the number of @@ -705,7 +711,7 @@ impl Builder { /// # { /// // `server_fut` is a future representing the completion of the HTTP/2.0 /// // handshake. - /// let server_fut = Server::builder() + /// let server_fut = Builder::new() /// .reset_stream_duration(Duration::from_secs(10)) /// .handshake(my_io); /// # server_fut @@ -723,7 +729,7 @@ impl Builder { /// It is expected that `io` already be in an appropriate state to commence /// the [HTTP/2.0 handshake]. See [Handshake] for more details. /// - /// Returns a future which resolves to the [`Server`] instance once the + /// Returns a future which resolves to the [`Connection`] instance once the /// HTTP/2.0 handshake has been completed. /// /// This function also allows the caller to configure the send payload data @@ -731,7 +737,7 @@ impl Builder { /// /// [HTTP/2.0 handshake]: http://httpwg.org/specs/rfc7540.html#ConnectionHeader /// [Handshake]: ../index.html#handshake - /// [`Server`]: struct.Server.html + /// [`Connection`]: struct.Connection.html /// [Outbound data type]: ../index.html#outbound-data-type. /// /// # Examples @@ -749,7 +755,7 @@ impl Builder { /// # { /// // `server_fut` is a future representing the completion of the HTTP/2.0 /// // handshake. - /// let handshake_fut = Server::builder() + /// let handshake_fut = Builder::new() /// .handshake(my_io); /// # handshake_fut /// # } @@ -771,7 +777,7 @@ impl Builder { /// # { /// // `server_fut` is a future representing the completion of the HTTP/2.0 /// // handshake. - /// let server_fut: Handshake<_, &'static [u8]> = Server::builder() + /// let server_fut: Handshake<_, &'static [u8]> = Builder::new() /// .handshake(my_io); /// # server_fut /// # } @@ -784,23 +790,19 @@ impl Builder { B: IntoBuf, B::Buf: 'static, { - Server::handshake2(io, self.clone()) + Connection::handshake2(io, self.clone()) } } impl Default for Builder { fn default() -> Builder { - Builder { - reset_stream_duration: Duration::from_secs(proto::DEFAULT_RESET_STREAM_SECS), - reset_stream_max: proto::DEFAULT_RESET_STREAM_MAX, - settings: Settings::default(), - } + Builder::new() } } -// ===== impl Respond ===== +// ===== impl SendResponse ===== -impl Respond { +impl SendResponse { /// Send a response to a client request. /// /// On success, a [`SendStream`] instance is returned. This instance can be @@ -810,11 +812,11 @@ impl Respond { /// instance, then `end_of_stream` must be set to `true` when calling this /// function. /// - /// The [`Respond`] instance is already associated with a received request. - /// This function may only be called once per instance and only if + /// The [`SendResponse`] instance is already associated with a received + /// request. This function may only be called once per instance and only if /// [`send_reset`] has not been previously called. /// - /// [`Respond`]: # + /// [`SendResponse`]: # /// [`SendStream`]: ../struct.SendStream.html /// [`send_reset`]: #method.send_reset pub fn send_response( @@ -924,7 +926,7 @@ impl Future for Handshake where T: AsyncRead + AsyncWrite, B: IntoBuf, { - type Item = Server; + type Item = Connection; type Error = ::Error; fn poll(&mut self) -> Poll { @@ -955,7 +957,7 @@ impl Future for Handshake }; let poll = if let ReadingPreface(ref mut read) = self.state { // We're now waiting for the client preface. Poll the `ReadPreface` - // future. If it has completed, we will create a `Server` handle + // future. If it has completed, we will create a `Connection` handle // for the connection. read.poll() // Actually creating the `Connection` has to occur outside of this @@ -966,14 +968,14 @@ impl Future for Handshake unreachable!("Handshake::poll() state was not advanced completely!") }; let server = poll?.map(|codec| { - let connection = Connection::new(codec, Config { + let connection = proto::Connection::new(codec, Config { next_stream_id: 2.into(), reset_stream_duration: self.builder.reset_stream_duration, reset_stream_max: self.builder.reset_stream_max, settings: self.builder.settings.clone(), }); trace!("Handshake::poll(); connection established!"); - Server { connection } + Connection { connection } }); Ok(server) } diff --git a/tests/client_request.rs b/tests/client_request.rs index 7ab7b51..cbaaf37 100644 --- a/tests/client_request.rs +++ b/tests/client_request.rs @@ -13,7 +13,7 @@ fn handshake() { .write(SETTINGS_ACK) .build(); - let (_, h2) = Client::handshake(mock).wait().unwrap(); + let (_, h2) = client::handshake(mock).wait().unwrap(); trace!("hands have been shook"); @@ -37,7 +37,7 @@ fn client_other_thread() { .send_frame(frames::headers(1).response(200).eos()) .close(); - let h2 = Client::handshake(io) + let h2 = client::handshake(io) .expect("handshake") .and_then(|(mut client, h2)| { ::std::thread::spawn(move || { @@ -76,7 +76,7 @@ fn recv_invalid_server_stream_id() { .write(&[0, 0, 8, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) .build(); - let (mut client, h2) = Client::handshake(mock).wait().unwrap(); + let (mut client, h2) = client::handshake(mock).wait().unwrap(); // Send the request let request = Request::builder() @@ -100,7 +100,7 @@ fn request_stream_id_overflows() { let (io, srv) = mock::new(); - let h2 = Client::builder() + let h2 = client::Builder::new() .initial_stream_id(::std::u32::MAX >> 1) .handshake::<_, Bytes>(io) .expect("handshake") @@ -172,7 +172,7 @@ fn client_builder_max_concurrent_streams() { .send_frame(frames::headers(1).response(200).eos()) .close(); - let mut builder = Client::builder(); + let mut builder = client::Builder::new(); builder.max_concurrent_streams(1); let h2 = builder @@ -219,7 +219,7 @@ fn request_over_max_concurrent_streams_errors() { .send_frame(frames::data(5, "").eos()) .close(); - let h2 = Client::handshake(io) + let h2 = client::handshake(io) .expect("handshake") .and_then(|(mut client, h2)| { // we send a simple req here just to drive the connection so we can @@ -294,7 +294,7 @@ fn http_11_request_without_scheme_or_authority() { .send_frame(frames::headers(1).response(200).eos()) .close(); - let h2 = Client::handshake(io) + let h2 = client::handshake(io) .expect("handshake") .and_then(|(mut client, h2)| { // we send a simple req here just to drive the connection so we can @@ -324,7 +324,7 @@ fn http_2_request_without_scheme_or_authority() { .recv_settings() .close(); - let h2 = Client::handshake(io) + let h2 = client::handshake(io) .expect("handshake") .and_then(|(mut client, h2)| { // we send a simple req here just to drive the connection so we can @@ -367,7 +367,7 @@ fn request_with_connection_headers() { ("te", "boom"), ]; - let client = Client::handshake(io) + let client = client::handshake(io) .expect("handshake") .and_then(move |(mut client, conn)| { for (name, val) in headers { @@ -402,7 +402,7 @@ fn connection_close_notifies_response_future() { // don't send any response, just close .close(); - let client = Client::handshake(io) + let client = client::handshake(io) .expect("handshake") .and_then(|(mut client, conn)| { let request = Request::builder() @@ -444,7 +444,7 @@ fn connection_close_notifies_client_poll_ready() { ) .close(); - let client = Client::handshake(io) + let client = client::handshake(io) .expect("handshake") .and_then(|(mut client, conn)| { let request = Request::builder() @@ -497,7 +497,7 @@ fn sending_request_on_closed_connection() { .send_frame(frames::headers(0).response(200).eos()) .close(); - let h2 = Client::handshake(io) + let h2 = client::handshake(io) .expect("handshake") .and_then(|(mut client, h2)| { let request = Request::builder() diff --git a/tests/codec_write.rs b/tests/codec_write.rs index 14a321f..06a374f 100644 --- a/tests/codec_write.rs +++ b/tests/codec_write.rs @@ -27,7 +27,7 @@ fn write_continuation_frames() { ) .close(); - let client = Client::handshake(io) + let client = client::handshake(io) .expect("handshake") .and_then(|(mut client, conn)| { let mut request = Request::builder(); diff --git a/tests/flow_control.rs b/tests/flow_control.rs index e8ee22e..673e2da 100644 --- a/tests/flow_control.rs +++ b/tests/flow_control.rs @@ -27,7 +27,7 @@ fn send_data_without_requesting_capacity() { .read(&[0, 0, 1, 1, 5, 0, 0, 0, 1, 0x89]) .build(); - let (mut client, mut h2) = Client::handshake(mock).wait().unwrap(); + let (mut client, mut h2) = client::handshake(mock).wait().unwrap(); let request = Request::builder() .method(Method::POST) @@ -82,7 +82,7 @@ fn release_capacity_sends_window_update() { // gotta end the connection .map(drop); - let h2 = Client::handshake(io).unwrap().and_then(|(mut client, h2)| { + let h2 = client::handshake(io).unwrap().and_then(|(mut client, h2)| { let request = Request::builder() .method(Method::GET) .uri("https://http2.akamai.com/") @@ -147,7 +147,7 @@ fn release_capacity_of_small_amount_does_not_send_window_update() { // gotta end the connection .map(drop); - let h2 = Client::handshake(io).unwrap().and_then(|(mut client, h2)| { + let h2 = client::handshake(io).unwrap().and_then(|(mut client, h2)| { let request = Request::builder() .method(Method::GET) .uri("https://http2.akamai.com/") @@ -216,7 +216,7 @@ fn recv_data_overflows_connection_window() { .recv_frame(frames::go_away(0).flow_control()); // connection is ended by client - let h2 = Client::handshake(io).unwrap().and_then(|(mut client, h2)| { + let h2 = client::handshake(io).unwrap().and_then(|(mut client, h2)| { let request = Request::builder() .method(Method::GET) .uri("https://http2.akamai.com/") @@ -279,7 +279,7 @@ fn recv_data_overflows_stream_window() { .recv_frame(frames::reset(1).flow_control()) .close(); - let h2 = Client::builder() + let h2 = client::Builder::new() .initial_window_size(16_384) .handshake::<_, Bytes>(io) .unwrap() @@ -348,7 +348,7 @@ fn stream_error_release_connection_capacity() { .recv_frame(frames::window_update(0, 16_384 * 2 + 10)) .close(); - let client = Client::handshake(io).unwrap() + let client = client::handshake(io).unwrap() .and_then(|(mut client, conn)| { let request = Request::builder() .uri("https://http2.akamai.com/") @@ -397,7 +397,7 @@ fn stream_close_by_data_frame_releases_capacity() { let window_size = frame::DEFAULT_INITIAL_WINDOW_SIZE as usize; - let h2 = Client::handshake(io).unwrap().and_then(|(mut client, h2)| { + let h2 = client::handshake(io).unwrap().and_then(|(mut client, h2)| { let request = Request::builder() .method(Method::POST) .uri("https://http2.akamai.com/") @@ -468,7 +468,7 @@ fn stream_close_by_trailers_frame_releases_capacity() { let window_size = frame::DEFAULT_INITIAL_WINDOW_SIZE as usize; - let h2 = Client::handshake(io).unwrap().and_then(|(mut client, h2)| { + let h2 = client::handshake(io).unwrap().and_then(|(mut client, h2)| { let request = Request::builder() .method(Method::POST) .uri("https://http2.akamai.com/") @@ -551,7 +551,7 @@ fn recv_window_update_on_stream_closed_by_data_frame() { let _ = ::env_logger::init(); let (io, srv) = mock::new(); - let h2 = Client::handshake(io) + let h2 = client::handshake(io) .unwrap() .and_then(|(mut client, h2)| { let request = Request::builder() @@ -600,7 +600,7 @@ fn reserved_capacity_assigned_in_multi_window_updates() { let _ = ::env_logger::init(); let (io, srv) = mock::new(); - let h2 = Client::handshake(io) + let h2 = client::handshake(io) .unwrap() .and_then(|(mut client, h2)| { let request = Request::builder() @@ -729,7 +729,7 @@ fn connection_notified_on_released_capacity() { let th2 = thread::spawn(move || { - let (mut client, h2) = Client::handshake(io).wait().unwrap(); + let (mut client, h2) = client::handshake(io).wait().unwrap(); let (h2, _) = h2.drive(settings_rx).wait().unwrap(); @@ -809,7 +809,7 @@ fn recv_settings_removes_available_capacity() { .close(); - let h2 = Client::handshake(io).unwrap() + let h2 = client::handshake(io).unwrap() .and_then(|(mut client, h2)| { let request = Request::builder() .method(Method::POST) @@ -870,7 +870,7 @@ fn recv_no_init_window_then_receive_some_init_window() { .close(); - let h2 = Client::handshake(io).unwrap() + let h2 = client::handshake(io).unwrap() .and_then(|(mut client, h2)| { let request = Request::builder() .method(Method::POST) @@ -971,7 +971,7 @@ fn settings_lowered_capacity_returns_capacity_to_connection() { .wait().unwrap(); }); - let (mut client, h2) = Client::handshake(io).unwrap() + let (mut client, h2) = client::handshake(io).unwrap() .wait().unwrap(); // Drive client connection @@ -1034,7 +1034,7 @@ fn client_increase_target_window_size() { .close(); - let client = Client::handshake(io).unwrap() + let client = client::handshake(io).unwrap() .and_then(|(_client, mut conn)| { conn.set_target_window_size(2 << 20); @@ -1062,7 +1062,7 @@ fn increase_target_window_size_after_using_some() { .recv_frame(frames::window_update(0, (2 << 20) - 65_535)) .close(); - let client = Client::handshake(io).unwrap() + let client = client::handshake(io).unwrap() .and_then(|(mut client, conn)| { let request = Request::builder() .uri("https://http2.akamai.com/") @@ -1105,7 +1105,7 @@ fn decrease_target_window_size() { .recv_frame(frames::window_update(0, 16_384)) .close(); - let client = Client::handshake(io).unwrap() + let client = client::handshake(io).unwrap() .and_then(|(mut client, mut conn)| { conn.set_target_window_size(16_384 * 2); @@ -1142,7 +1142,7 @@ fn server_target_window_size() { .recv_frame(frames::window_update(0, (2 << 20) - 65_535)) .close(); - let srv = Server::handshake(io).unwrap() + let srv = server::handshake(io).unwrap() .and_then(|mut conn| { conn.set_target_window_size(2 << 20); conn.into_future().unwrap() @@ -1180,7 +1180,7 @@ fn recv_settings_increase_window_size_after_using_some() { .send_frame(frames::headers(1).response(200).eos()) .close(); - let client = Client::handshake(io).unwrap() + let client = client::handshake(io).unwrap() .and_then(|(mut client, conn)| { let request = Request::builder() .method("POST") diff --git a/tests/ping_pong.rs b/tests/ping_pong.rs index 94df301..a7becd3 100644 --- a/tests/ping_pong.rs +++ b/tests/ping_pong.rs @@ -8,7 +8,7 @@ fn recv_single_ping() { let (m, mock) = mock::new(); // Create the handshake - let h2 = Client::handshake(m) + let h2 = client::handshake(m) .unwrap() .and_then(|(_, conn)| conn.unwrap()); @@ -49,7 +49,7 @@ fn recv_multiple_pings() { .recv_frame(frames::ping([2; 8]).pong()) .close(); - let srv = Server::handshake(io) + let srv = server::handshake(io) .expect("handshake") .and_then(|srv| { // future of first request, which never comes @@ -79,7 +79,7 @@ fn pong_has_highest_priority() { .recv_frame(frames::headers(1).response(200).eos()) .close(); - let srv = Server::handshake(io) + let srv = server::handshake(io) .expect("handshake") .and_then(|srv| { // future of first request diff --git a/tests/prioritization.rs b/tests/prioritization.rs index 734b893..fd9a3d6 100644 --- a/tests/prioritization.rs +++ b/tests/prioritization.rs @@ -26,7 +26,7 @@ fn single_stream_send_large_body() { .build(); let notify = MockNotify::new(); - let (mut client, mut h2) = Client::handshake(mock).wait().unwrap(); + let (mut client, mut h2) = client::handshake(mock).wait().unwrap(); // Poll h2 once to get notifications loop { @@ -94,7 +94,7 @@ fn single_stream_send_extra_large_body_multi_frames_one_buffer() { .build(); let notify = MockNotify::new(); - let (mut client, mut h2) = Client::handshake(mock).wait().unwrap(); + let (mut client, mut h2) = client::handshake(mock).wait().unwrap(); // Poll h2 once to get notifications loop { @@ -181,7 +181,7 @@ fn single_stream_send_body_greater_than_default_window() { .build(); let notify = MockNotify::new(); - let (mut client, mut h2) = Client::handshake(mock).wait().unwrap(); + let (mut client, mut h2) = client::handshake(mock).wait().unwrap(); // Poll h2 once to get notifications loop { @@ -265,7 +265,7 @@ fn single_stream_send_extra_large_body_multi_frames_multi_buffer() { .read(&[0, 0, 1, 1, 5, 0, 0, 0, 1, 0x89]) .build(); - let (mut client, mut h2) = Client::handshake(mock).wait().unwrap(); + let (mut client, mut h2) = client::handshake(mock).wait().unwrap(); let request = Request::builder() .method(Method::POST) @@ -296,7 +296,7 @@ fn send_data_receive_window_update() { let _ = ::env_logger::init(); let (m, mock) = mock::new(); - let h2 = Client::handshake(m) + let h2 = client::handshake(m) .unwrap() .and_then(|(mut client, h2)| { let request = Request::builder() diff --git a/tests/push_promise.rs b/tests/push_promise.rs index c1e92ba..1c38023 100644 --- a/tests/push_promise.rs +++ b/tests/push_promise.rs @@ -20,7 +20,7 @@ fn recv_push_works() { .send_frame(frames::headers(1).response(200).eos()) .send_frame(frames::headers(2).response(200).eos()); - let h2 = Client::handshake(io).unwrap().and_then(|(mut client, h2)| { + let h2 = client::handshake(io).unwrap().and_then(|(mut client, h2)| { let request = Request::builder() .method(Method::GET) .uri("https://http2.akamai.com/") @@ -58,7 +58,7 @@ fn recv_push_when_push_disabled_is_conn_error() { .send_frame(frames::headers(1).response(200).eos()) .recv_frame(frames::go_away(0).protocol_error()); - let h2 = Client::builder() + let h2 = client::Builder::new() .enable_push(false) .handshake::<_, Bytes>(io) .unwrap() @@ -115,7 +115,7 @@ fn pending_push_promises_reset_when_dropped() { .recv_frame(frames::reset(2).cancel()) .close(); - let client = Client::handshake(io).unwrap().and_then(|(mut client, conn)| { + let client = client::handshake(io).unwrap().and_then(|(mut client, conn)| { let request = Request::builder() .method(Method::GET) .uri("https://http2.akamai.com/") diff --git a/tests/server.rs b/tests/server.rs index fb052a6..cf8a87f 100644 --- a/tests/server.rs +++ b/tests/server.rs @@ -17,7 +17,7 @@ fn read_preface_in_multiple_frames() { .read(SETTINGS_ACK) .build(); - let h2 = Server::handshake(mock).wait().unwrap(); + let h2 = server::handshake(mock).wait().unwrap(); assert!(Stream::wait(h2).next().is_none()); } @@ -47,7 +47,7 @@ fn server_builder_set_max_concurrent_streams() { .recv_frame(frames::headers(1).response(200).eos()) .close(); - let mut builder = Server::builder(); + let mut builder = server::Builder::new(); builder.max_concurrent_streams(1); let h2 = builder @@ -89,7 +89,7 @@ fn serve_request() { .recv_frame(frames::headers(1).response(200).eos()) .close(); - let srv = Server::handshake(io).expect("handshake").and_then(|srv| { + let srv = server::handshake(io).expect("handshake").and_then(|srv| { srv.into_future().unwrap().and_then(|(reqstream, srv)| { let (req, mut stream) = reqstream.unwrap(); @@ -129,7 +129,7 @@ fn recv_invalid_authority() { .recv_frame(frames::reset(1).protocol_error()) .close(); - let srv = Server::handshake(io) + let srv = server::handshake(io) .expect("handshake") .and_then(|srv| srv.into_future().unwrap()); @@ -164,7 +164,7 @@ fn recv_connection_header() { .recv_frame(frames::reset(9).protocol_error()) .close(); - let srv = Server::handshake(io) + let srv = server::handshake(io) .expect("handshake") .and_then(|srv| srv.into_future().unwrap()); @@ -188,7 +188,7 @@ fn sends_reset_cancel_when_body_is_dropped() { .recv_frame(frames::reset(1).cancel()) .close(); - let srv = Server::handshake(io).expect("handshake").and_then(|srv| { + let srv = server::handshake(io).expect("handshake").and_then(|srv| { srv.into_future().unwrap().and_then(|(reqstream, srv)| { let (req, mut stream) = reqstream.unwrap(); diff --git a/tests/stream_states.rs b/tests/stream_states.rs index d01e5bb..0238a57 100644 --- a/tests/stream_states.rs +++ b/tests/stream_states.rs @@ -20,7 +20,7 @@ fn send_recv_headers_only() { .read(&[0, 0, 1, 1, 5, 0, 0, 0, 1, 0x89]) .build(); - let (mut client, mut h2) = Client::handshake(mock).wait().unwrap(); + let (mut client, mut h2) = client::handshake(mock).wait().unwrap(); // Send the request let request = Request::builder() @@ -62,7 +62,7 @@ fn send_recv_data() { ]) .build(); - let (mut client, mut h2) = Client::builder().handshake(mock).wait().unwrap(); + let (mut client, mut h2) = client::Builder::new().handshake(mock).wait().unwrap(); let request = Request::builder() .method(Method::POST) @@ -119,7 +119,7 @@ fn send_headers_recv_data_single_frame() { ]) .build(); - let (mut client, mut h2) = Client::handshake(mock).wait().unwrap(); + let (mut client, mut h2) = client::handshake(mock).wait().unwrap(); // Send the request let request = Request::builder() @@ -154,7 +154,7 @@ fn closed_streams_are_released() { let _ = ::env_logger::init(); let (io, srv) = mock::new(); - let h2 = Client::handshake(io).unwrap().and_then(|(mut client, h2)| { + let h2 = client::handshake(io).unwrap().and_then(|(mut client, h2)| { let request = Request::get("https://example.com/").body(()).unwrap(); // Send request @@ -199,7 +199,7 @@ fn errors_if_recv_frame_exceeds_max_frame_size() { let _ = ::env_logger::init(); let (io, mut srv) = mock::new(); - let h2 = Client::handshake(io).unwrap().and_then(|(mut client, h2)| { + let h2 = client::handshake(io).unwrap().and_then(|(mut client, h2)| { let request = Request::builder() .method(Method::GET) .uri("https://example.com/") @@ -254,7 +254,7 @@ fn configure_max_frame_size() { let _ = ::env_logger::init(); let (io, mut srv) = mock::new(); - let h2 = Client::builder() + let h2 = client::Builder::new() .max_frame_size(16_384 * 2) .handshake::<_, Bytes>(io) .expect("handshake") @@ -325,7 +325,7 @@ fn recv_goaway_finishes_processed_streams() { .recv_frame(frames::go_away(0)); //.close(); - let h2 = Client::handshake(io) + let h2 = client::handshake(io) .expect("handshake") .and_then(|(mut client, h2)| { let request = Request::builder() @@ -396,7 +396,7 @@ fn recv_next_stream_id_updated_by_malformed_headers() { .recv_frame(frames::go_away(1).protocol_error()) .close(); - let srv = Server::handshake(io) + let srv = server::handshake(io) .expect("handshake") .and_then(|srv| srv.into_future().then(|res| { let (err, _) = res.unwrap_err(); @@ -429,7 +429,7 @@ fn skipped_stream_ids_are_implicitly_closed() { // implicitly closed. .send_frame(frames::headers(3).response(200)); - let h2 = Client::builder() + let h2 = client::Builder::new() .initial_stream_id(5) .handshake::<_, Bytes>(io) .expect("handshake") @@ -491,7 +491,7 @@ fn send_rst_stream_allows_recv_data() { .ping_pong([1; 8]) .close(); - let client = Client::handshake(io) + let client = client::handshake(io) .expect("handshake") .and_then(|(mut client, conn)| { let request = Request::builder() @@ -540,7 +540,7 @@ fn send_rst_stream_allows_recv_trailers() { .ping_pong([1; 8]) .close(); - let client = Client::handshake(io) + let client = client::handshake(io) .expect("handshake") .and_then(|(mut client, conn)| { let request = Request::builder() @@ -591,7 +591,7 @@ fn rst_stream_expires() { .recv_frame(frames::go_away(0).protocol_error()) .close(); - let client = Client::builder() + let client = client::Builder::new() .reset_stream_duration(Duration::from_millis(10)) .handshake::<_, Bytes>(io) .expect("handshake") @@ -663,7 +663,7 @@ fn rst_stream_max() { .recv_frame(frames::go_away(0).protocol_error()) .close(); - let client = Client::builder() + let client = client::Builder::new() .max_concurrent_reset_streams(1) .handshake::<_, Bytes>(io) .expect("handshake") @@ -744,7 +744,7 @@ fn reserved_state_recv_window_update() { .ping_pong([1; 8]) .close(); - let client = Client::handshake(io) + let client = client::handshake(io) .expect("handshake") .and_then(|(mut client, conn)| { let request = Request::builder() diff --git a/tests/support/prelude.rs b/tests/support/prelude.rs index a72a57b..3bf75b8 100644 --- a/tests/support/prelude.rs +++ b/tests/support/prelude.rs @@ -3,9 +3,9 @@ pub use super::h2; pub use self::h2::*; -pub use self::h2::client::{self, Client}; +pub use self::h2::client; pub use self::h2::frame::StreamId; -pub use self::h2::server::{self, Server}; +pub use self::h2::server; // Re-export mock pub use super::mock::{self, HandleFutureExt}; diff --git a/tests/trailers.rs b/tests/trailers.rs index f584990..397b5ab 100644 --- a/tests/trailers.rs +++ b/tests/trailers.rs @@ -23,7 +23,7 @@ fn recv_trailers_only() { ]) .build(); - let (mut client, mut h2) = Client::handshake(mock).wait().unwrap(); + let (mut client, mut h2) = client::handshake(mock).wait().unwrap(); // Send the request let request = Request::builder() @@ -71,7 +71,7 @@ fn send_trailers_immediately() { ]) .build(); - let (mut client, mut h2) = Client::handshake(mock).wait().unwrap(); + let (mut client, mut h2) = client::handshake(mock).wait().unwrap(); // Send the request let request = Request::builder()