Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add sending host headers with requests #46

Merged
merged 1 commit into from
Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions test-suite/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ pub struct TestConfig {
#[derive(Clone, Debug)]
pub struct ServerConfig {
pub host: String,
pub host_header: Option<String>,
pub port: u16,
pub critical: bool,
}
Expand Down Expand Up @@ -214,6 +215,9 @@ async fn run_test_once(
server_config.host, server_config.port, test_case.test_route
);
let mut request = client.get(&url);
if let Some(host_header) = server_config.host_header.as_ref() {
request = request.header("Host", host_header);
}
if let Some(timeout) = test_case.timeout {
request = request.timeout(std::time::Duration::from_secs_f64(timeout));
}
Expand Down
5 changes: 5 additions & 0 deletions test-suite/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ struct TestSuiteArguments {
#[arg(long)]
host: Option<String>,

/// If set, send Host header with requests
#[arg(long)]
host_header: Option<String>,

/// Defaults to 8080
#[arg(long)]
port: Option<u16>,
Expand Down Expand Up @@ -68,6 +72,7 @@ fn main() -> Result<()> {
let test_config = read_test_cases(args.test_config_path)?;
let server_config = ServerConfig {
host: args.host.unwrap_or_else(|| "localhost".to_string()),
host_header: args.host_header,
port: args.port.unwrap_or(8080),
critical: !args.not_critical,
};
Expand Down