From 06f0126fad7e321644c807ba929678edd98964d2 Mon Sep 17 00:00:00 2001 From: Sean McArthur Date: Fri, 16 Mar 2018 17:43:31 -0700 Subject: [PATCH] refactor(lib): clean up unused dependencies --- Cargo.toml | 6 ------ src/headers.rs | 18 ++++++++++++++---- src/lib.rs | 2 -- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 31620180..b5713262 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,7 +21,6 @@ include = [ ] [dependencies] -base64 = "0.9" bytes = "0.4.4" futures = "0.1.17" futures-cpupool = "0.1.6" @@ -29,18 +28,13 @@ futures-timer = "0.1.0" http = "0.1.5" httparse = "1.0" iovec = "0.1" -language-tags = "0.2" log = "0.4" -mime = "0.3.2" net2 = "0.2.32" -percent-encoding = "1.0" -relay = "0.1" time = "0.1" tokio = "0.1.3" tokio-executor = "0.1.0" tokio-service = "0.1" tokio-io = "0.1" -unicase = "2.0" [dev-dependencies] num_cpus = "1.0" diff --git a/src/headers.rs b/src/headers.rs index 1cad1ba9..47e13032 100644 --- a/src/headers.rs +++ b/src/headers.rs @@ -4,7 +4,6 @@ use bytes::BytesMut; use http::HeaderMap; use http::header::{CONNECTION, CONTENT_LENGTH, EXPECT, TRANSFER_ENCODING}; use http::header::{HeaderValue, OccupiedEntry, ValueIter}; -use unicase; /// Maximum number of bytes needed to serialize a u64 into ASCII decimal. const MAX_DECIMAL_U64_BYTES: usize = 20; @@ -13,7 +12,7 @@ pub fn connection_keep_alive(headers: &HeaderMap) -> bool { for line in headers.get_all(CONNECTION) { if let Ok(s) = line.to_str() { for val in s.split(',') { - if unicase::eq_ascii(val.trim(), "keep-alive") { + if eq_ascii(val.trim(), "keep-alive") { return true; } } @@ -27,7 +26,7 @@ pub fn connection_close(headers: &HeaderMap) -> bool { for line in headers.get_all(CONNECTION) { if let Ok(s) = line.to_str() { for val in s.split(',') { - if unicase::eq_ascii(val.trim(), "close") { + if eq_ascii(val.trim(), "close") { return true; } } @@ -98,7 +97,7 @@ pub fn is_chunked(mut encodings: ValueIter) -> bool { if let Some(line) = encodings.next_back() { if let Ok(s) = line.to_str() { if let Some(encoding) = s.rsplit(',').next() { - return unicase::eq_ascii(encoding.trim(), "chunked"); + return eq_ascii(encoding.trim(), "chunked"); } } } @@ -125,6 +124,17 @@ pub fn add_chunked(mut entry: OccupiedEntry) { entry.insert(HeaderValue::from_static(CHUNKED)); } +fn eq_ascii(left: &str, right: &str) -> bool { + // As of Rust 1.23, str gained this method inherently, and so the + // compiler says this trait is unused. + // + // Once our minimum Rust compiler version is >=1.23, this can be removed. + #[allow(unused)] + use std::ascii::AsciiExt; + + left.eq_ignore_ascii_case(right) +} + #[cfg(test)] mod tests { #[test] diff --git a/src/lib.rs b/src/lib.rs index f3952502..cf1702d1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -25,13 +25,11 @@ extern crate httparse; extern crate iovec; #[macro_use] extern crate log; extern crate net2; -extern crate relay; extern crate time; extern crate tokio; extern crate tokio_executor; #[macro_use] extern crate tokio_io; extern crate tokio_service; -extern crate unicase; #[cfg(all(test, feature = "nightly"))] extern crate test;