use base_http::Version;
use base_http_fixtures::{Context, ServerContext, protocol::App};
use base_scheduler_native::NativeScheduler;
fn serve(app: App, version: Version) -> ServerContext<App> {
ServerContext::new().handler(app).version(version)
}
fn http11(app: App, test: impl AsyncFnOnce(&Context<'_, NativeScheduler, App>)) {
serve(app, Version::Http11).run(test);
}
mod http11 {
base_http_fixtures::protocol_tests!(run: super::http11);
base_http_fixtures::protocol_trailer_tests!(run: super::http11);
}
fn http10(app: App, test: impl AsyncFnOnce(&Context<'_, NativeScheduler, App>)) {
serve(app, Version::Http10).run(test);
}
mod http10 {
base_http_fixtures::protocol_tests!(run: super::http10);
base_http_fixtures::protocol_trailer_tests!(run: super::http10);
}
#[cfg(feature = "rustls")]
fn https(app: App, test: impl AsyncFnOnce(&Context<'_, NativeScheduler, App>)) {
serve(app, Version::Http11).tls().run(test);
}
#[cfg(feature = "rustls")]
mod https {
base_http_fixtures::protocol_tests!(run: super::https);
base_http_fixtures::protocol_trailer_tests!(run: super::https);
}
fn http11_spawned(app: App, test: impl AsyncFnOnce(&Context<'_, NativeScheduler, App>)) {
serve(app, Version::Http11).run_spawned(test);
}
mod http11_spawned {
base_http_fixtures::protocol_tests!(run: super::http11_spawned);
base_http_fixtures::protocol_trailer_tests!(run: super::http11_spawned);
}
fn http10_spawned(app: App, test: impl AsyncFnOnce(&Context<'_, NativeScheduler, App>)) {
serve(app, Version::Http10).run_spawned(test);
}
mod http10_spawned {
base_http_fixtures::protocol_tests!(run: super::http10_spawned);
base_http_fixtures::protocol_trailer_tests!(run: super::http10_spawned);
}
#[cfg(feature = "rustls")]
fn https_spawned(app: App, test: impl AsyncFnOnce(&Context<'_, NativeScheduler, App>)) {
serve(app, Version::Http11).tls().run_spawned(test);
}
#[cfg(feature = "rustls")]
mod https_spawned {
base_http_fixtures::protocol_tests!(run: super::https_spawned);
base_http_fixtures::protocol_trailer_tests!(run: super::https_spawned);
}