Skip to content

Commit

Permalink
fix: HTTP/3 realization doesn't work (#816)
Browse files Browse the repository at this point in the history
* fix: HTTP/3 realization doesn't work

* wip
  • Loading branch information
chrislearn authored Jun 20, 2024
1 parent 31038ed commit 8a1c6c4
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion crates/core/src/conn/quinn/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ impl Builder {
break;
}
Err(e) => {
tracing::warn!(error = ?e, "accept failed");
tracing::debug!(error = ?e, "accept stopped {:?}", e.get_error_level());
match e.get_error_level() {
ErrorLevel::ConnectionError => break,
ErrorLevel::StreamError => continue,
Expand Down
9 changes: 7 additions & 2 deletions crates/core/src/conn/rustls/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,12 @@ impl RustlsConfig {
certified_keys,
fallback,
}));
config.alpn_protocols = self.alpn_protocols;
let mut alpn_protocols = self.alpn_protocols;
let h3_alpn = b"h3".to_vec();
if !alpn_protocols.contains(&h3_alpn) {
alpn_protocols.push(h3_alpn);
}
config.alpn_protocols = alpn_protocols;
Ok(config)
}

Expand All @@ -278,7 +283,7 @@ cfg_feature! {
type Error = IoError;

fn try_into(self) -> IoResult<crate::conn::quinn::ServerConfig> {
let crypto = quinn::crypto::rustls::QuicServerConfig::try_from(self.build_server_config()?).map_err(|_|IoError::new(ErrorKind::Other, "failed to build quic server config"))?;
let crypto = quinn::crypto::rustls::QuicServerConfig::try_from(self.build_server_config()?).map_err(|_|IoError::new(ErrorKind::Other, "failed to build quinn server config"))?;
Ok(crate::conn::quinn::ServerConfig::with_crypto(Arc::new(crypto)))
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
//! | `server` | Built-in Server implementation | ✔️ |
//! | `http1` | Support for HTTP 1.1 protocol | ✔️ |
//! | `http2` | Support for HTTP 2 protocol | ✔️ |
//! | `http2-cleartext` | Support for HTTP 2 over cleartext TCP | ✔️ |
//! | `http2-cleartext` | Support for HTTP 2 over cleartext TCP | |
//! | `quinn` | Use [quinn](https://crates.io/crates/quinn) to support HTTP 3 protocol | ❌ |
//! | `test` | Utilities for testing application | ✔️ |
//! | `acme` | Automatically obtain certificates through ACME | ❌ |
Expand Down
4 changes: 2 additions & 2 deletions crates/core/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ impl<A: Acceptor + Send> Server<A> {
alt_svc_h3 = Some(
format!(r#"h3=":{port}"; ma=2592000,h3-29=":{port}"; ma=2592000"#)
.parse::<HeaderValue>()
.expect("Parse alt-svc header failed."),
.expect("Parse alt-svc header should not failed."),
);
}
}
Expand Down Expand Up @@ -361,7 +361,7 @@ impl<A: Acceptor + Send> Server<A> {
alt_svc_h3 = Some(
format!(r#"h3=":{port}"; ma=2592000,h3-29=":{port}"; ma=2592000"#)
.parse::<HeaderValue>()
.expect("Parse alt-svc header failed."),
.expect("Parse alt-svc header should not failed."),
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/salvo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
//! | `server` | Built-in Server implementation | ✔️ |
//! | `http1` | Support for HTTP 1.1 protocol | ✔️ |
//! | `http2` | Support for HTTP 2 protocol | ✔️ |
//! | `http2-cleartext` | Support for HTTP 2 over cleartext TCP | ✔️ |
//! | `http2-cleartext` | Support for HTTP 2 over cleartext TCP | |
//! | `quinn` | Use [quinn](https://crates.io/crates/quinn) to support HTTP 3 protocol | ❌ |
//! | `test` | Utilities for testing application | ✔️ |
//! | `acme` | Automatically obtain certificates through ACME | ❌ |
Expand Down

0 comments on commit 8a1c6c4

Please sign in to comment.