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 accept encoding test without qvalues #2822

Merged
merged 1 commit into from
Dec 5, 2023
Merged
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
25 changes: 24 additions & 1 deletion src/subcommand/server/accept_encoding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ mod tests {
}

#[tokio::test]
async fn accepts_encoding() {
async fn accepts_encoding_with_qvalues() {
let req = Request::builder()
.header(ACCEPT_ENCODING, "deflate;q=0.5, gzip;q=1.0, br;q=0.8")
.body(())
Expand All @@ -90,7 +90,30 @@ mod tests {
assert!(encodings.is_acceptable(&HeaderValue::from_static("deflate")));
assert!(encodings.is_acceptable(&HeaderValue::from_static("gzip")));
assert!(encodings.is_acceptable(&HeaderValue::from_static("br")));
assert!(!encodings.is_acceptable(&HeaderValue::from_static("bzip2")));
}

#[tokio::test]
async fn accepts_encoding_without_qvalues() {
let req = Request::builder()
.header(ACCEPT_ENCODING, "gzip, deflate, br")
.body(())
.unwrap();

let encodings = AcceptEncoding::from_request_parts(
&mut req.into_parts().0,
&Arc::new(ServerConfig {
is_json_api_enabled: false,
}),
)
.await
.unwrap();

assert_eq!(encodings.0, Some("gzip, deflate, br".to_string()));

assert!(encodings.is_acceptable(&HeaderValue::from_static("deflate")));
assert!(encodings.is_acceptable(&HeaderValue::from_static("gzip")));
assert!(encodings.is_acceptable(&HeaderValue::from_static("br")));
assert!(!encodings.is_acceptable(&HeaderValue::from_static("bzip2")));
}
}
Loading