rust_web_server/http/
mod.rs1#[cfg(test)]
2mod tests;
3
4pub struct Version {
5 pub http_0_9: &'static str,
6 pub http_1_0: &'static str,
7 pub http_1_1: &'static str,
8 pub http_2_0: &'static str,
9 pub http_3_0: &'static str,
10}
11
12pub const VERSION: Version = Version {
13 http_0_9: "HTTP/0.9",
14 http_1_0: "HTTP/1.0",
15 http_1_1: "HTTP/1.1",
16 http_2_0: "HTTP/2.0",
17 http_3_0: "HTTP/3.0",
18};
19
20pub struct HTTP;
21
22impl HTTP {
23 pub fn is_supported_version(version: &str) -> bool {
26 [VERSION.http_0_9, VERSION.http_1_0, VERSION.http_1_1, VERSION.http_2_0, VERSION.http_3_0]
27 .iter()
28 .any(|v| v.eq_ignore_ascii_case(version))
29 }
30
31 pub fn version_list() -> Vec<String> {
32 let version_0_9 = VERSION.http_0_9.to_string();
33 let version_1_0 = VERSION.http_1_0.to_string();
34 let version_1_1 = VERSION.http_1_1.to_string();
35 let version_2_0 = VERSION.http_2_0.to_string();
36 let version_3_0 = VERSION.http_3_0.to_string();
37
38 let list : Vec<String> = vec![
39 version_0_9,
40 version_1_0,
41 version_1_1,
42 version_2_0,
43 version_3_0,
44 ];
45 list
46 }
47}