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
use std::borrow::Cow;
use header::Connection;
use header::ConnectionOption::{KeepAlive, Close};
use header::Headers;
use version::HttpVersion;
use version::HttpVersion::{Http10, Http11};
pub use self::message::{HttpMessage, RequestHead, ResponseHead, Protocol};
pub mod h1;
pub mod h2;
pub mod message;
#[derive(Clone, PartialEq, Debug)]
pub struct RawStatus(pub u16, pub Cow<'static, str>);
#[inline]
pub fn should_keep_alive(version: HttpVersion, headers: &Headers) -> bool {
trace!("should_keep_alive( {:?}, {:?} )", version, headers.get::<Connection>());
match (version, headers.get::<Connection>()) {
(Http10, Some(conn)) if !conn.contains(&KeepAlive) => false,
(Http11, Some(conn)) if conn.contains(&Close) => false,
_ => true
}
}