From cee8692d8177a1da9d50f50efe9015f95038967a Mon Sep 17 00:00:00 2001 From: Sean McArthur Date: Tue, 13 Jun 2017 10:55:12 -0700 Subject: [PATCH] refactor(header): replace url crate with percent-encoding --- Cargo.toml | 2 +- src/header/parsing.rs | 17 ++++++----------- src/lib.rs | 4 ++-- 3 files changed, 9 insertions(+), 14 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index dae09fcf..5b285669 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,13 +27,13 @@ httparse = "1.0" language-tags = "0.2" log = "0.3" mime = "0.3.2" +percent-encoding = "1.0" time = "0.1" tokio-core = "0.1.6" tokio-proto = "0.1" tokio-service = "0.1" tokio-io = "0.1" unicase = "2.0" -url = "1.0" [dev-dependencies] num_cpus = "1.0" diff --git a/src/header/parsing.rs b/src/header/parsing.rs index 0f65fb2f..ed89cfba 100644 --- a/src/header/parsing.rs +++ b/src/header/parsing.rs @@ -4,7 +4,7 @@ use language_tags::LanguageTag; use std::str; use std::str::FromStr; use std::fmt::{self, Display}; -use url::percent_encoding; +use percent_encoding; use header::Raw; use header::shared::Charset; @@ -156,23 +156,18 @@ pub fn http_percent_encode(f: &mut fmt::Formatter, bytes: &[u8]) -> fmt::Result } mod percent_encoding_http { - use std::fmt; - use url::percent_encoding; + use percent_encoding; + // internal module because macro is hard-coded to make a public item + // but we don't want to public export this item define_encode_set! { - /// This encode set is used for HTTP header values and is defined at - /// https://tools.ietf.org/html/rfc5987#section-3.2 + // This encode set is used for HTTP header values and is defined at + // https://tools.ietf.org/html/rfc5987#section-3.2 pub HTTP_VALUE = [percent_encoding::SIMPLE_ENCODE_SET] | { ' ', '"', '%', '\'', '(', ')', '*', ',', '/', ':', ';', '<', '-', '>', '?', '[', '\\', ']', '{', '}' } } - - impl fmt::Debug for HTTP_VALUE { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.pad("HTTP_VALUE") - } - } } #[cfg(test)] diff --git a/src/lib.rs b/src/lib.rs index ad5ec7ce..9eb9516d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -17,6 +17,7 @@ //! If just starting out, **check out the [Guides](https://hyper.rs/guides) //! first.** +extern crate base64; extern crate bytes; #[macro_use] extern crate futures; extern crate futures_cpupool; @@ -24,14 +25,13 @@ extern crate httparse; extern crate language_tags; #[macro_use] extern crate log; pub extern crate mime; -extern crate base64; +#[macro_use] extern crate percent_encoding; extern crate time; extern crate tokio_core as tokio; #[macro_use] extern crate tokio_io; extern crate tokio_proto; extern crate tokio_service; extern crate unicase; -#[macro_use] extern crate url; #[cfg(all(test, feature = "nightly"))] extern crate test;