1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
//! Pieces pertaining to the HTTP message protocol.
use ;
pub use ;
pub
pub
/// An Incoming Message head. Includes request/status line, and headers.
/// An incoming request message.
pub type RequestHead = ;
;
/// An incoming response message.
pub type ResponseHead = ;
/*
impl<S> MessageHead<S> {
pub fn should_keep_alive(&self) -> bool {
should_keep_alive(self.version, &self.headers)
}
pub fn expecting_continue(&self) -> bool {
expecting_continue(self.version, &self.headers)
}
}
/// Checks if a connection should be kept alive.
#[inline]
pub fn should_keep_alive(version: Version, headers: &HeaderMap) -> bool {
if version == Version::HTTP_10 {
headers::connection_keep_alive(headers)
} else {
!headers::connection_close(headers)
}
}
/// Checks if a connection is expecting a `100 Continue` before sending its body.
#[inline]
pub fn expecting_continue(version: Version, headers: &HeaderMap) -> bool {
version == Version::HTTP_11 && headers::expect_continue(headers)
}
*/
/*
#[test]
fn test_should_keep_alive() {
let mut headers = HeaderMap::new();
assert!(!should_keep_alive(Version::HTTP_10, &headers));
assert!(should_keep_alive(Version::HTTP_11, &headers));
headers.insert("connection", ::http::header::HeaderValue::from_static("close"));
assert!(!should_keep_alive(Version::HTTP_10, &headers));
assert!(!should_keep_alive(Version::HTTP_11, &headers));
headers.insert("connection", ::http::header::HeaderValue::from_static("keep-alive"));
assert!(should_keep_alive(Version::HTTP_10, &headers));
assert!(should_keep_alive(Version::HTTP_11, &headers));
}
#[test]
fn test_expecting_continue() {
let mut headers = HeaderMap::new();
assert!(!expecting_continue(Version::HTTP_10, &headers));
assert!(!expecting_continue(Version::HTTP_11, &headers));
headers.insert("expect", ::http::header::HeaderValue::from_static("100-continue"));
assert!(!expecting_continue(Version::HTTP_10, &headers));
assert!(expecting_continue(Version::HTTP_11, &headers));
}
*/