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