1
0
mirror of https://github.com/fafhrd91/actix-web synced 2025-09-01 01:16:59 +02:00

better naming

This commit is contained in:
Nikolay Kim
2017-10-08 14:56:51 -07:00
parent 3036152581
commit 63b78b6461
11 changed files with 100 additions and 81 deletions

View File

@@ -164,6 +164,21 @@ impl HttpRequest {
}
}
/// Is keepalive enabled by client?
pub fn keep_alive(&self) -> bool {
let ret = match (self.version(), self.headers().get::<Connection>()) {
(Version::HTTP_10, None) => false,
(Version::HTTP_10, Some(conn))
if !conn.contains(&ConnectionOption::KeepAlive) => false,
(Version::HTTP_11, Some(conn))
if conn.contains(&ConnectionOption::Close) => false,
_ => true
};
trace!("should_keep_alive(version={:?}, header={:?}) = {:?}",
self.version(), self.headers().get::<Connection>(), ret);
ret
}
pub(crate) fn is_upgrade(&self) -> bool {
if let Some(&Connection(ref conn)) = self.headers().get() {
conn.contains(&ConnectionOption::from_str("upgrade").unwrap())
@@ -199,7 +214,7 @@ impl Body {
}
}
/// Implements by something that can be converted to `HttpMessage`
/// Implements by something that can be converted to `HttpResponse`
pub trait IntoHttpResponse {
/// Convert into response.
fn response(self, req: HttpRequest) -> HttpResponse;