mirror of https://github.com/fafhrd91/actix-web
set the actix-web client send the http2 packet without ssl.
This commit is contained in:
parent
8c54054844
commit
f056e9f44b
|
@ -206,6 +206,38 @@ where
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Finish configuration process and create connector service wich http2 set.
|
||||||
|
pub fn finish_for_h2(
|
||||||
|
self,
|
||||||
|
) -> impl Service<Request = Connect, Response = impl Connection, Error = ConnectError>
|
||||||
|
+ Clone {
|
||||||
|
let connector = TimeoutService::new(
|
||||||
|
self.timeout,
|
||||||
|
apply_fn(self.connector, |msg: Connect, srv| {
|
||||||
|
srv.call(TcpConnect::new(msg.uri).set_addr(msg.addr))
|
||||||
|
})
|
||||||
|
.map_err(ConnectError::from)
|
||||||
|
.map(|stream| {
|
||||||
|
let sock = stream.into_parts().0;
|
||||||
|
(Box::new(sock) as Box<dyn Io>, Protocol::Http2)
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
.map_err(|e| match e {
|
||||||
|
TimeoutError::Service(e) => e,
|
||||||
|
TimeoutError::Timeout => ConnectError::Timeout,
|
||||||
|
});
|
||||||
|
|
||||||
|
connect_impl::InnerConnector {
|
||||||
|
tcp_pool: ConnectionPool::new(
|
||||||
|
connector,
|
||||||
|
self.conn_lifetime,
|
||||||
|
self.conn_keep_alive,
|
||||||
|
None,
|
||||||
|
self.limit,
|
||||||
|
),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Finish configuration process and create connector service.
|
/// Finish configuration process and create connector service.
|
||||||
/// The Connector builder always concludes by calling `finish()` last in
|
/// The Connector builder always concludes by calling `finish()` last in
|
||||||
/// its combinator chain.
|
/// its combinator chain.
|
||||||
|
|
|
@ -96,6 +96,17 @@ impl Client {
|
||||||
Client::default()
|
Client::default()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Create new client instance with http2 settings.
|
||||||
|
pub fn set_http2() -> Client {
|
||||||
|
Client(Rc::new(ClientConfig {
|
||||||
|
connector: RefCell::new(Box::new(ConnectorWrapper(
|
||||||
|
Connector::new().finish_for_h2(),
|
||||||
|
))),
|
||||||
|
headers: HeaderMap::new(),
|
||||||
|
timeout: Some(Duration::from_secs(5)),
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
|
||||||
/// Build client instance.
|
/// Build client instance.
|
||||||
pub fn build() -> ClientBuilder {
|
pub fn build() -> ClientBuilder {
|
||||||
ClientBuilder::new()
|
ClientBuilder::new()
|
||||||
|
|
Loading…
Reference in New Issue