Skip to content

Commit 9cbcd80

Browse files
committed
Fix #182: Convert error codes before passing them to QUIC
1 parent 209a6c9 commit 9cbcd80

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

wtransport/src/driver/mod.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ impl Driver {
137137

138138
stream
139139
.into_stream()
140-
.stop(ErrorCode::BufferedStreamRejected.to_code())
140+
.stop(ErrorCode::BufferedStreamRejected.to_http3())
141141
.expect("Stream not already stopped");
142142
}
143143
}
@@ -164,7 +164,7 @@ impl Driver {
164164
stream
165165
.into_stream()
166166
.1
167-
.stop(ErrorCode::BufferedStreamRejected.to_code())
167+
.stop(ErrorCode::BufferedStreamRejected.to_http3())
168168
.expect("Stream not already stopped");
169169
}
170170
}
@@ -308,7 +308,7 @@ mod worker {
308308

309309
if let DriverError::Proto(error_code) = &error {
310310
self.quic_connection
311-
.close(varint_w2q(error_code.to_code()), b"");
311+
.close(varint_w2q(error_code.to_http3()), b"");
312312
}
313313

314314
self.driver_result.set(error);
@@ -595,14 +595,14 @@ mod worker {
595595
Ok(session_request) => stream.into_session(session_request),
596596
Err(HeadersParseError::MethodNotConnect) => {
597597
stream
598-
.stop(ErrorCode::RequestRejected.to_code())
598+
.stop(ErrorCode::RequestRejected.to_http3())
599599
.expect("Stream not already stopped");
600600
return Ok(());
601601
}
602602
// TODO(biagio): we might have more granularity with errors
603603
Err(_) => {
604604
stream
605-
.stop(ErrorCode::Message.to_code())
605+
.stop(ErrorCode::Message.to_http3())
606606
.expect("Stream not already stopped");
607607
return Ok(());
608608
}
@@ -613,7 +613,7 @@ mod worker {
613613
Err(TrySendError::Full(mut stream)) => {
614614
debug!("Discarding session request: sessions queue is full");
615615
stream
616-
.stop(ErrorCode::RequestRejected.to_code())
616+
.stop(ErrorCode::RequestRejected.to_http3())
617617
.expect("Stream not already stopped");
618618
}
619619
Err(TrySendError::Closed(_)) => return Err(DriverError::NotConnected),

wtransport/src/endpoint.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ impl Endpoint<endpoint_side::Client> {
387387
let frame = match stream_session.read_frame().await {
388388
Ok(frame) => frame,
389389
Err(ProtoReadError::H3(error_code)) => {
390-
quic_connection.close(varint_w2q(error_code.to_code()), b"");
390+
quic_connection.close(varint_w2q(error_code.to_http3()), b"");
391391
return Err(ConnectingError::ConnectionError(
392392
ConnectionError::local_h3_error(error_code),
393393
));
@@ -404,7 +404,7 @@ impl Endpoint<endpoint_side::Client> {
404404
};
405405

406406
if !matches!(frame.kind(), FrameKind::Headers) {
407-
quic_connection.close(varint_w2q(ErrorCode::FrameUnexpected.to_code()), b"");
407+
quic_connection.close(varint_w2q(ErrorCode::FrameUnexpected.to_http3()), b"");
408408
return Err(ConnectingError::ConnectionError(
409409
ConnectionError::local_h3_error(ErrorCode::FrameUnexpected),
410410
));
@@ -413,7 +413,7 @@ impl Endpoint<endpoint_side::Client> {
413413
let headers = match Headers::with_frame(&frame) {
414414
Ok(headers) => headers,
415415
Err(error_code) => {
416-
quic_connection.close(varint_w2q(error_code.to_code()), b"");
416+
quic_connection.close(varint_w2q(error_code.to_http3()), b"");
417417
return Err(ConnectingError::ConnectionError(
418418
ConnectionError::local_h3_error(error_code),
419419
));
@@ -423,7 +423,7 @@ impl Endpoint<endpoint_side::Client> {
423423
let session_response = match SessionResponseProto::try_from(headers) {
424424
Ok(session_response) => session_response,
425425
Err(_) => {
426-
quic_connection.close(varint_w2q(ErrorCode::Message.to_code()), b"");
426+
quic_connection.close(varint_w2q(ErrorCode::Message.to_http3()), b"");
427427
return Err(ConnectingError::ConnectionError(
428428
ConnectionError::local_h3_error(ErrorCode::Message),
429429
));
@@ -759,7 +759,7 @@ impl SessionRequest {
759759
}
760760
Err(ProtoWriteError::Stopped) => {
761761
self.quic_connection
762-
.close(varint_w2q(ErrorCode::ClosedCriticalStream.to_code()), b"");
762+
.close(varint_w2q(ErrorCode::ClosedCriticalStream.to_http3()), b"");
763763

764764
Err(ConnectionError::local_h3_error(
765765
ErrorCode::ClosedCriticalStream,

0 commit comments

Comments
 (0)