Skip to content

Commit e713098

Browse files
authored
Include ntex-error (#794)
1 parent 0480c05 commit e713098

File tree

4 files changed

+48
-19
lines changed

4 files changed

+48
-19
lines changed

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ ntex-macros = { path = "ntex-macros" }
5353
ntex-util = { path = "ntex-util" }
5454

5555
[workspace.dependencies]
56-
ntex = "3.5.1"
56+
ntex = "3.6.0"
5757
ntex-bytes = "1.5.2"
5858
ntex-codec = "1.1.0"
5959
ntex-error = "1.0.0"
@@ -68,7 +68,7 @@ ntex-service = "4.6.0"
6868
ntex-tls = "3.4.0"
6969
ntex-macros = "3.2.0"
7070
ntex-util = "3.4.0"
71-
ntex-h2 = "3.7.1"
71+
ntex-h2 = "3.8.0"
7272

7373
ntex-polling = "3.10.0"
7474
ntex-io-uring = "0.7.120"

ntex/CHANGES.md

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

3+
## [3.6.0] - 2026-03-08
4+
5+
* Include ntex-error
6+
7+
* web: Configure web test server port #790
8+
39
## [3.5.1] - 2026-02-19
410

511
* Fix http client request version

ntex/src/client/h2proto.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use std::{future::poll_fn, io, rc::Rc};
22

33
use ntex_h2::{self as h2, client::RecvStream, client::SimpleClient, frame};
44

5+
use crate::error::Error;
56
use crate::http::ResponseHead;
67
use crate::http::body::{Body, BodySize, MessageBody};
78
use crate::http::header::{self, HeaderMap, HeaderValue};
@@ -69,7 +70,8 @@ pub(super) async fn send_request(
6970
let (snd_stream, rcv_stream) = client
7071
.client
7172
.send(req.head.method.clone(), path, hdrs, eof)
72-
.await?;
73+
.await
74+
.map_err(Error::into_error)?;
7375

7476
// send body
7577
if !eof {
@@ -164,7 +166,7 @@ async fn get_response(
164166
pl.feed_eof(Bytes::new());
165167
}
166168
h2::StreamEof::Error(err) => {
167-
pl.set_error(err.into());
169+
pl.set_error(err.into_error().into());
168170
}
169171
}
170172
}
@@ -223,12 +225,18 @@ async fn send_body(
223225
stream.id(),
224226
b.len()
225227
);
226-
stream.send_payload(b, false).await?;
228+
stream
229+
.send_payload(b, false)
230+
.await
231+
.map_err(Error::into_error)?;
227232
}
228233
Some(Err(e)) => return Err(e.into()),
229234
None => {
230235
log::trace!("{}: {:?} eof of send stream ", stream.tag(), stream.id());
231-
stream.send_payload(Bytes::new(), true).await?;
236+
stream
237+
.send_payload(Bytes::new(), true)
238+
.await
239+
.map_err(Error::into_error)?;
232240
return Ok(());
233241
}
234242
}

ntex/src/http/h2/service.rs

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
use std::cell::{Cell, RefCell};
2-
use std::{error::Error, fmt, future::poll_fn, io, marker, mem, rc::Rc, task::Context};
2+
use std::{
3+
error::Error as StdError, fmt, future::poll_fn, io, marker, mem, rc::Rc, task::Context,
4+
};
35

46
use ntex_h2::{self as h2, frame::StreamId, server};
57

68
use crate::channel::oneshot;
9+
use crate::error::Error;
710
use crate::http::body::{BodySize, MessageBody};
811
use crate::http::config::DispatcherConfig;
912
use crate::http::error::{DispatchError, H2Error, ResponseError};
@@ -62,7 +65,7 @@ mod openssl {
6265
B: MessageBody,
6366
C: ServiceFactory<h2::Control<H2Error>, SharedCfg, Response = h2::ControlAck>
6467
+ 'static,
65-
C::Error: Error,
68+
C::Error: StdError,
6669
C::InitError: fmt::Debug,
6770
{
6871
/// Create ssl based service
@@ -103,7 +106,7 @@ mod rustls {
103106
B: MessageBody,
104107
C: ServiceFactory<h2::Control<H2Error>, SharedCfg, Response = h2::ControlAck>
105108
+ 'static,
106-
C::Error: Error,
109+
C::Error: StdError,
107110
C::InitError: fmt::Debug,
108111
{
109112
/// Create openssl based service
@@ -137,14 +140,14 @@ where
137140
S::InitError: fmt::Debug,
138141
B: MessageBody,
139142
C: ServiceFactory<h2::Control<H2Error>, SharedCfg, Response = h2::ControlAck>,
140-
C::Error: Error,
143+
C::Error: StdError,
141144
C::InitError: fmt::Debug,
142145
{
143146
/// Provide http/2 control service
144147
pub fn control<CT>(self, ctl: CT) -> H2Service<F, S, B, CT>
145148
where
146149
CT: ServiceFactory<h2::Control<H2Error>, SharedCfg, Response = h2::ControlAck>,
147-
CT::Error: Error,
150+
CT::Error: StdError,
148151
CT::InitError: fmt::Debug,
149152
{
150153
H2Service {
@@ -164,7 +167,7 @@ where
164167
S::Response: Into<Response<B>>,
165168
B: MessageBody,
166169
C: ServiceFactory<h2::Control<H2Error>, SharedCfg, Response = h2::ControlAck> + 'static,
167-
C::Error: Error,
170+
C::Error: StdError,
168171
C::InitError: fmt::Debug,
169172
{
170173
type Response = ();
@@ -213,7 +216,7 @@ where
213216
S::Response: Into<Response<B>>,
214217
B: MessageBody,
215218
C: ServiceFactory<h2::Control<H2Error>, SharedCfg, Response = h2::ControlAck> + 'static,
216-
C::Error: Error,
219+
C::Error: StdError,
217220
C::InitError: fmt::Debug,
218221
{
219222
type Response = ();
@@ -311,7 +314,7 @@ where
311314
S::Response: Into<Response<B>>,
312315
B: MessageBody,
313316
C2: Service<h2::Control<H2Error>, Response = h2::ControlAck> + 'static,
314-
C2::Error: Error,
317+
C2::Error: StdError,
315318
{
316319
let ioref = io.get_ref();
317320

@@ -415,7 +418,9 @@ where
415418
h2::StreamEof::Trailers(_) => {
416419
sender.feed_eof(Bytes::new());
417420
}
418-
h2::StreamEof::Error(err) => sender.set_error(err.into()),
421+
h2::StreamEof::Error(err) => {
422+
sender.set_error(err.into_error().into());
423+
}
419424
}
420425
}
421426
return Ok(());
@@ -480,9 +485,13 @@ where
480485

481486
let hdrs = mem::replace(&mut head.headers, HeaderMap::new());
482487
if size.is_eof() || is_head_req {
483-
stream.send_response(head.status, hdrs, true)?;
488+
stream
489+
.send_response(head.status, hdrs, true)
490+
.map_err(Error::into_error)?;
484491
} else {
485-
stream.send_response(head.status, hdrs, false)?;
492+
stream
493+
.send_response(head.status, hdrs, false)
494+
.map_err(Error::into_error)?;
486495

487496
loop {
488497
match poll_fn(|cx| body.poll_next_chunk(cx)).await {
@@ -492,7 +501,10 @@ where
492501
self.io.tag(),
493502
stream.id()
494503
);
495-
stream.send_payload(Bytes::new(), true).await?;
504+
stream
505+
.send_payload(Bytes::new(), true)
506+
.await
507+
.map_err(Error::into_error)?;
496508
break;
497509
}
498510
Some(Ok(chunk)) => {
@@ -503,7 +515,10 @@ where
503515
chunk.len()
504516
);
505517
if !chunk.is_empty() {
506-
stream.send_payload(chunk, false).await?;
518+
stream
519+
.send_payload(chunk, false)
520+
.await
521+
.map_err(Error::into_error)?;
507522
}
508523
}
509524
Some(Err(e)) => {

0 commit comments

Comments
 (0)