Skip to content

Commit cee8692

Browse files
committed
refactor(header): replace url crate with percent-encoding
1 parent d09288e commit cee8692

File tree

3 files changed

+9
-14
lines changed

3 files changed

+9
-14
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ httparse = "1.0"
2727
language-tags = "0.2"
2828
log = "0.3"
2929
mime = "0.3.2"
30+
percent-encoding = "1.0"
3031
time = "0.1"
3132
tokio-core = "0.1.6"
3233
tokio-proto = "0.1"
3334
tokio-service = "0.1"
3435
tokio-io = "0.1"
3536
unicase = "2.0"
36-
url = "1.0"
3737

3838
[dev-dependencies]
3939
num_cpus = "1.0"

src/header/parsing.rs

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use language_tags::LanguageTag;
44
use std::str;
55
use std::str::FromStr;
66
use std::fmt::{self, Display};
7-
use url::percent_encoding;
7+
use percent_encoding;
88

99
use header::Raw;
1010
use header::shared::Charset;
@@ -156,23 +156,18 @@ pub fn http_percent_encode(f: &mut fmt::Formatter, bytes: &[u8]) -> fmt::Result
156156
}
157157

158158
mod percent_encoding_http {
159-
use std::fmt;
160-
use url::percent_encoding;
159+
use percent_encoding;
161160

161+
// internal module because macro is hard-coded to make a public item
162+
// but we don't want to public export this item
162163
define_encode_set! {
163-
/// This encode set is used for HTTP header values and is defined at
164-
/// https://tools.ietf.org/html/rfc5987#section-3.2
164+
// This encode set is used for HTTP header values and is defined at
165+
// https://tools.ietf.org/html/rfc5987#section-3.2
165166
pub HTTP_VALUE = [percent_encoding::SIMPLE_ENCODE_SET] | {
166167
' ', '"', '%', '\'', '(', ')', '*', ',', '/', ':', ';', '<', '-', '>', '?',
167168
'[', '\\', ']', '{', '}'
168169
}
169170
}
170-
171-
impl fmt::Debug for HTTP_VALUE {
172-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
173-
f.pad("HTTP_VALUE")
174-
}
175-
}
176171
}
177172

178173
#[cfg(test)]

src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,21 @@
1717
//! If just starting out, **check out the [Guides](https://hyper.rs/guides)
1818
//! first.**
1919
20+
extern crate base64;
2021
extern crate bytes;
2122
#[macro_use] extern crate futures;
2223
extern crate futures_cpupool;
2324
extern crate httparse;
2425
extern crate language_tags;
2526
#[macro_use] extern crate log;
2627
pub extern crate mime;
27-
extern crate base64;
28+
#[macro_use] extern crate percent_encoding;
2829
extern crate time;
2930
extern crate tokio_core as tokio;
3031
#[macro_use] extern crate tokio_io;
3132
extern crate tokio_proto;
3233
extern crate tokio_service;
3334
extern crate unicase;
34-
#[macro_use] extern crate url;
3535

3636
#[cfg(all(test, feature = "nightly"))]
3737
extern crate test;

0 commit comments

Comments
 (0)