1
0
Fork 0
mirror of https://github.com/actix/actix-web.git synced 2024-06-02 21:39:26 +00:00

actix-http: update ws example, tests for rustls 0.23

This commit is contained in:
asonix 2024-05-12 17:08:54 -05:00
parent d7f5bcef95
commit a16d713678
2 changed files with 24 additions and 24 deletions

View file

@ -1,7 +1,7 @@
//! Sets up a WebSocket server over TCP and TLS.
//! Sends a heartbeat message every 4 seconds but does not respond to any incoming frames.
extern crate tls_rustls_022 as rustls;
extern crate tls_rustls_023 as rustls;
use std::{
io,
@ -30,7 +30,7 @@ async fn main() -> io::Result<()> {
.bind("tls", ("127.0.0.1", 8443), || {
HttpService::build()
.finish(handler)
.rustls_0_22(tls_config())
.rustls_0_23(tls_config())
})?
.run()
.await

View file

@ -1,6 +1,6 @@
#![cfg(feature = "rustls-0_22")]
#![cfg(feature = "rustls-0_23")]
extern crate tls_rustls_022 as rustls;
extern crate tls_rustls_023 as rustls;
use std::{
convert::Infallible,
@ -20,7 +20,7 @@ use actix_http::{
use actix_http_test::test_server;
use actix_rt::pin;
use actix_service::{fn_factory_with_config, fn_service};
use actix_tls::connect::rustls_0_22::webpki_roots_cert_store;
use actix_tls::connect::rustls_0_23::webpki_roots_cert_store;
use actix_utils::future::{err, ok, poll_fn};
use bytes::{Bytes, BytesMut};
use derive_more::{Display, Error};
@ -108,7 +108,7 @@ async fn h1() -> io::Result<()> {
let srv = test_server(move || {
HttpService::build()
.h1(|_| ok::<_, Error>(Response::ok()))
.rustls_0_22(tls_config())
.rustls_0_23(tls_config())
})
.await;
@ -122,7 +122,7 @@ async fn h2() -> io::Result<()> {
let srv = test_server(move || {
HttpService::build()
.h2(|_| ok::<_, Error>(Response::ok()))
.rustls_0_22(tls_config())
.rustls_0_23(tls_config())
})
.await;
@ -140,7 +140,7 @@ async fn h1_1() -> io::Result<()> {
assert_eq!(req.version(), Version::HTTP_11);
ok::<_, Error>(Response::ok())
})
.rustls_0_22(tls_config())
.rustls_0_23(tls_config())
})
.await;
@ -158,7 +158,7 @@ async fn h2_1() -> io::Result<()> {
assert_eq!(req.version(), Version::HTTP_2);
ok::<_, Error>(Response::ok())
})
.rustls_0_22_with_config(
.rustls_0_23_with_config(
tls_config(),
TlsAcceptorConfig::default().handshake_timeout(Duration::from_secs(5)),
)
@ -179,7 +179,7 @@ async fn h2_body1() -> io::Result<()> {
let body = load_body(req.take_payload()).await?;
Ok::<_, Error>(Response::ok().set_body(body))
})
.rustls_0_22(tls_config())
.rustls_0_23(tls_config())
})
.await;
@ -205,7 +205,7 @@ async fn h2_content_length() {
];
ok::<_, Infallible>(Response::new(statuses[indx]))
})
.rustls_0_22(tls_config())
.rustls_0_23(tls_config())
})
.await;
@ -277,7 +277,7 @@ async fn h2_headers() {
}
ok::<_, Infallible>(config.body(data.clone()))
})
.rustls_0_22(tls_config())
.rustls_0_23(tls_config())
})
.await;
@ -316,7 +316,7 @@ async fn h2_body2() {
let mut srv = test_server(move || {
HttpService::build()
.h2(|_| ok::<_, Infallible>(Response::ok().set_body(STR)))
.rustls_0_22(tls_config())
.rustls_0_23(tls_config())
})
.await;
@ -333,7 +333,7 @@ async fn h2_head_empty() {
let mut srv = test_server(move || {
HttpService::build()
.finish(|_| ok::<_, Infallible>(Response::ok().set_body(STR)))
.rustls_0_22(tls_config())
.rustls_0_23(tls_config())
})
.await;
@ -359,7 +359,7 @@ async fn h2_head_binary() {
let mut srv = test_server(move || {
HttpService::build()
.h2(|_| ok::<_, Infallible>(Response::ok().set_body(STR)))
.rustls_0_22(tls_config())
.rustls_0_23(tls_config())
})
.await;
@ -384,7 +384,7 @@ async fn h2_head_binary2() {
let srv = test_server(move || {
HttpService::build()
.h2(|_| ok::<_, Infallible>(Response::ok().set_body(STR)))
.rustls_0_22(tls_config())
.rustls_0_23(tls_config())
})
.await;
@ -410,7 +410,7 @@ async fn h2_body_length() {
Response::ok().set_body(SizedStream::new(STR.len() as u64, body)),
)
})
.rustls_0_22(tls_config())
.rustls_0_23(tls_config())
})
.await;
@ -434,7 +434,7 @@ async fn h2_body_chunked_explicit() {
.body(BodyStream::new(body)),
)
})
.rustls_0_22(tls_config())
.rustls_0_23(tls_config())
})
.await;
@ -463,7 +463,7 @@ async fn h2_response_http_error_handling() {
)
}))
}))
.rustls_0_22(tls_config())
.rustls_0_23(tls_config())
})
.await;
@ -493,7 +493,7 @@ async fn h2_service_error() {
let mut srv = test_server(move || {
HttpService::build()
.h2(|_| err::<Response<BoxBody>, _>(BadRequest))
.rustls_0_22(tls_config())
.rustls_0_23(tls_config())
})
.await;
@ -510,7 +510,7 @@ async fn h1_service_error() {
let mut srv = test_server(move || {
HttpService::build()
.h1(|_| err::<Response<BoxBody>, _>(BadRequest))
.rustls_0_22(tls_config())
.rustls_0_23(tls_config())
})
.await;
@ -533,7 +533,7 @@ async fn alpn_h1() -> io::Result<()> {
config.alpn_protocols.push(CUSTOM_ALPN_PROTOCOL.to_vec());
HttpService::build()
.h1(|_| ok::<_, Error>(Response::ok()))
.rustls_0_22(config)
.rustls_0_23(config)
})
.await;
@ -555,7 +555,7 @@ async fn alpn_h2() -> io::Result<()> {
config.alpn_protocols.push(CUSTOM_ALPN_PROTOCOL.to_vec());
HttpService::build()
.h2(|_| ok::<_, Error>(Response::ok()))
.rustls_0_22(config)
.rustls_0_23(config)
})
.await;
@ -581,7 +581,7 @@ async fn alpn_h2_1() -> io::Result<()> {
config.alpn_protocols.push(CUSTOM_ALPN_PROTOCOL.to_vec());
HttpService::build()
.finish(|_| ok::<_, Error>(Response::ok()))
.rustls_0_22(config)
.rustls_0_23(config)
})
.await;