Use new h2 client api

This commit is contained in:
Nikolay Kim 2022-07-13 13:38:22 +02:00
parent 064e3b5b8f
commit d808574b97
3 changed files with 17 additions and 14 deletions

View file

@ -1,5 +1,9 @@
# Changes
## [0.5.23] - 2022-07-13
* http: Use new h2 client api
## [0.5.22] - 2022-07-12
* http: Handle h2 connection disconnect

View file

@ -1,6 +1,6 @@
[package]
name = "ntex"
version = "0.5.22"
version = "0.5.23"
authors = ["ntex contributors <team@ntex.rs>"]
description = "Framework for composable network services"
readme = "README.md"
@ -56,7 +56,7 @@ ntex-service = "0.3.2"
ntex-macros = "0.1.3"
ntex-util = "0.1.17"
ntex-bytes = "0.1.16"
ntex-h2 = "0.1.3"
ntex-h2 = "0.1.4"
ntex-rt = "0.4.4"
ntex-io = "0.1.8"
ntex-tls = "0.1.5"

View file

@ -7,7 +7,7 @@ use ntex_h2::{self as h2};
use crate::http::uri::{Authority, Scheme, Uri};
use crate::io::{types::HttpProtocol, IoBoxed};
use crate::time::{now, Millis};
use crate::util::{ready, HashMap, HashSet};
use crate::util::{ready, ByteString, HashMap, HashSet};
use crate::{channel::pool, rt::spawn, service::Service, task::LocalWaker};
use super::connection::{Connection, ConnectionType};
@ -456,20 +456,19 @@ where
"Connection for {:?} is established, start http2 handshake",
&this.key.authority
);
let connection = h2::client::ClientConnection::new(
let auth = if let Some(auth) = this.uri.authority() {
format!("{}", auth).into()
} else {
ByteString::new()
};
let connection = h2::client::ClientConnection::with_params(
io,
this.inner.borrow().h2config.clone(),
this.uri.scheme() == Some(&Scheme::HTTPS),
auth,
);
let mut client = connection.client();
if this.uri.scheme() == Some(&Scheme::HTTPS) {
client.set_scheme(Scheme::HTTPS);
}
if let Some(auth) = this.uri.authority() {
let auth = format!("{}", auth);
client.set_authority(auth.into());
}
let client = H2Client::new(client);
let client = H2Client::new(connection.client());
let key = this.key.clone();
let publish = H2PublishService::new(client.clone());
crate::rt::spawn(async move {