Skip to content

Commit d3d26b5

Browse files
authored
Expose client internal connection object (#44)
1 parent 2fb8e6b commit d3d26b5

File tree

11 files changed

+31
-33
lines changed

11 files changed

+31
-33
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changes
22

3+
## [1.6.1] - 2025-01-14
4+
5+
* Expose client internal connection object
6+
37
## [1.6.0] - 2025-01-13
48

59
* Expose client internal information

Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "ntex-h2"
3-
version = "1.6.0"
3+
version = "1.6.1"
44
license = "MIT OR Apache-2.0"
55
authors = ["Nikolay Kim <[email protected]>"]
66
description = "An HTTP/2 client and server"
@@ -30,7 +30,6 @@ ntex-bytes = "0.1"
3030
ntex-codec = "0.6"
3131
ntex-service = "3.4"
3232
ntex-util = "2.8"
33-
ntex-rt = "0.4"
3433

3534
bitflags = "2"
3635
fxhash = "0.2"

src/client/connector.rs

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::{marker::PhantomData, ops};
22

3-
use ntex_bytes::{ByteString, PoolId};
3+
use ntex_bytes::ByteString;
44
use ntex_http::uri::Scheme;
55
use ntex_io::IoBoxed;
66
use ntex_net::connect::{self as connect, Address, Connect, Connector as DefaultConnector};
@@ -79,16 +79,6 @@ where
7979
self
8080
}
8181

82-
#[doc(hidden)]
83-
#[deprecated]
84-
/// Set memory pool.
85-
///
86-
/// Use specified memory pool for memory allocations. By default P5
87-
/// memory pool is used.
88-
pub fn memory_pool(&mut self, _: PoolId) -> &mut Self {
89-
self
90-
}
91-
9282
/// Use custom connector
9383
pub fn connector<U, F>(&self, connector: F) -> Connector<A, U>
9484
where
@@ -125,9 +115,9 @@ where
125115
))
126116
};
127117

128-
match timeout_checked(self.config.0.handshake_timeout.get(), fut).await {
129-
Ok(res) => res.map_err(From::from),
130-
Err(_) => Err(ClientError::HandshakeTimeout),
131-
}
118+
timeout_checked(self.config.0.handshake_timeout.get(), fut)
119+
.await
120+
.map_err(|_| ClientError::HandshakeTimeout)
121+
.and_then(|item| item)
132122
}
133123
}

src/client/pool.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ impl Client {
236236
where
237237
F: FnOnce(&[SimpleClient]) -> R,
238238
{
239-
f(&*self.inner.connections.borrow())
239+
f(&self.inner.connections.borrow())
240240
}
241241
}
242242

src/client/simple.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,12 @@ impl SimpleClient {
157157
pub fn io_ref(&self) -> &IoRef {
158158
self.0.con.io()
159159
}
160+
161+
#[doc(hidden)]
162+
/// Get access to underlining http/2 connection object
163+
pub fn connection(&self) -> &Connection {
164+
&self.0.con
165+
}
160166
}
161167

162168
impl Drop for SimpleClient {

src/connection.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -798,6 +798,8 @@ impl fmt::Debug for Connection {
798798
)
799799
.field("remote_window_sz", &self.0.remote_window_sz.get())
800800
.field("remote_frame_size", &self.0.remote_frame_size.get())
801+
.field("flags", &self.0.flags.get())
802+
.field("error", &self.check_error())
801803
.finish()
802804
}
803805
}

src/dispatcher.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ where
136136
if let Err(e) = self.inner.publish.poll(cx) {
137137
let inner = self.inner.clone();
138138
let con = self.connection.connection();
139-
ntex_rt::spawn(async move {
139+
ntex_util::spawn(async move {
140140
if inner.control.call_nowait(Control::error(e)).await.is_ok() {
141141
con.close();
142142
}

src/frame/headers.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ impl PseudoHeaders {
309309

310310
// ===== impl Iter =====
311311

312-
impl<'a> Iterator for Iter<'a> {
312+
impl Iterator for Iter<'_> {
313313
type Item = hpack::Header<Option<HeaderName>>;
314314

315315
fn next(&mut self) -> Option<Self::Item> {

src/hpack/header.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ impl From<Header> for Header<Option<HeaderName>> {
221221
}
222222
}
223223

224-
impl<'a> Name<'a> {
224+
impl Name<'_> {
225225
pub fn into_entry(self, value: Bytes) -> Result<Header, DecoderError> {
226226
match self {
227227
Name::Field(name) => Ok(Header::Field {

src/hpack/huffman/table.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ pub const ENCODE_TABLE: [(usize, u64); 257] = [
262262
];
263263

264264
// (next-state, byte, flags)
265-
pub const DECODE_TABLE: [[(usize, u8, u8); 16]; 256] = [
265+
pub static DECODE_TABLE: [[(usize, u8, u8); 16]; 256] = [
266266
// 0
267267
[
268268
(4, 0, 0x00),

0 commit comments

Comments
 (0)