Skip to content

Commit

Permalink
Merge pull request #46 from barankaraaslan/me/add-host-header
Browse files Browse the repository at this point in the history
add sending host headers with requests
  • Loading branch information
syrusakbary authored Mar 8, 2024
2 parents f713c70 + 873e9f7 commit fef1139
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
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

0 comments on commit fef1139

Please sign in to comment.