armature_security/content_type_options.rs
1//! X-Content-Type-Options
2//!
3//! Prevents browsers from MIME-sniffing away from declared content type.
4
5/// Content Type Options
6#[derive(Debug, Clone, Copy, PartialEq, Eq)]
7pub enum ContentTypeOptions {
8 /// Prevent MIME sniffing
9 NoSniff,
10}
11
12impl ContentTypeOptions {
13 pub fn to_header_value(&self) -> String {
14 match self {
15 Self::NoSniff => "nosniff".to_string(),
16 }
17 }
18}
19
20#[cfg(test)]
21mod tests {
22 use super::*;
23
24 #[test]
25 fn test_content_type_options() {
26 assert_eq!(ContentTypeOptions::NoSniff.to_header_value(), "nosniff");
27 }
28}