diff --git a/actix-http/src/client/h2proto.rs b/actix-http/src/client/h2proto.rs index 69d20752a..3f609f94d 100644 --- a/actix-http/src/client/h2proto.rs +++ b/actix-http/src/client/h2proto.rs @@ -1,11 +1,12 @@ use std::convert::TryFrom; use std::time; +use std::future::Future; use actix_codec::{AsyncRead, AsyncWrite}; use bytes::Bytes; use futures_util::future::poll_fn; use futures_util::pin_mut; -use h2::{client::SendRequest, SendStream}; +use h2::{client::{SendRequest, Connection, Builder}, SendStream}; use http::header::{HeaderValue, CONNECTION, CONTENT_LENGTH, TRANSFER_ENCODING}; use http::{request::Request, Method, Version}; @@ -185,3 +186,21 @@ fn release( } } } + + +// These values are taken from hyper/src/proto/h2/client.rs +const DEFAULT_H2_CONN_WINDOW: u32 = 1024 * 1024 * 5; // 5mb +const DEFAULT_H2_STREAM_WINDOW: u32 = 1024 * 1024 * 2; // 2mb + +pub(crate) fn handshake(io: Io) + -> impl Future, Connection), h2::Error>> +where + Io: AsyncRead + AsyncWrite + Unpin + 'static, +{ + let mut builder = Builder::new(); + builder + .initial_window_size(DEFAULT_H2_CONN_WINDOW) + .initial_connection_window_size(DEFAULT_H2_STREAM_WINDOW) + .enable_push(false); + builder.handshake(io) +} diff --git a/actix-http/src/client/pool.rs b/actix-http/src/client/pool.rs index 38a51b558..7bc862576 100644 --- a/actix-http/src/client/pool.rs +++ b/actix-http/src/client/pool.rs @@ -13,12 +13,13 @@ use actix_utils::{oneshot, task::LocalWaker}; use bytes::Bytes; use futures_util::future::{poll_fn, FutureExt, LocalBoxFuture}; use fxhash::FxHashMap; -use h2::client::{handshake, Connection, SendRequest}; +use h2::client::{Connection, SendRequest}; use http::uri::Authority; use indexmap::IndexSet; use pin_project::pin_project; use slab::Slab; +use super::h2proto::handshake; use super::connection::{ConnectionType, IoConnection}; use super::error::ConnectError; use super::Connect; @@ -593,7 +594,7 @@ where Some(Acquired(this.key.clone(), this.inner.take())), ))); Poll::Ready(()) - } else { + } else { *this.h2 = Some(handshake(io).boxed_local()); self.poll(cx) }