Skip to content

Commit

Permalink
parse user-agent as single value headers
Browse files Browse the repository at this point in the history
  • Loading branch information
kageru committed Apr 17, 2024
1 parent ea9d333 commit 6a617b7
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions rust/pact_models/src/headers.rs
@@ -1,13 +1,14 @@
pub static PARAMETERISED_HEADERS: [&str; 2] = ["accept", "content-type"];
pub static SINGLE_VALUE_HEADERS: [&str; 8] = [
pub static SINGLE_VALUE_HEADERS: [&str; 9] = [
"date",
"accept-datetime",
"if-modified-since",
"if-unmodified-since",
"expires",
"retry-after",
"last-modified",
"set-cookie"
"set-cookie",
"user-agent",
];

/// Tries to parse the header value into multiple values, taking into account headers that should
Expand Down Expand Up @@ -49,4 +50,10 @@ mod tests {
let parsed = parse_header("Last-Modified", "Mon, 01 Dec 2008 01:15:39 GMT");
expect!(parsed).to(be_equal_to(vec!["Mon, 01 Dec 2008 01:15:39 GMT"]));
}

#[test]
fn parse_user_agent_as_single_value() {
let parsed = parse_header("User-Agent", "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) QtWebEngine/6.6.3 Chrome/112.0.5615.213 Safari/537.36");
expect!(parsed).to(be_equal_to(vec!["Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) QtWebEngine/6.6.3 Chrome/112.0.5615.213 Safari/537.36"]));
}
}

0 comments on commit 6a617b7

Please sign in to comment.