refactor(hyper): Update to rust-url 1.0

BREAKING CHANGE: The re-exported Url type has breaking changes.
This commit is contained in:
Simon Sapin
2016-04-22 01:14:08 +02:00
committed by Sean McArthur
parent 4bdf52a482
commit 8fa7a98968
9 changed files with 54 additions and 54 deletions

View File

@@ -12,7 +12,7 @@ use unicase::UniCase;
use url::percent_encoding;
use header::{Header, HeaderFormat, parsing};
use header::parsing::parse_extended_value;
use header::parsing::{parse_extended_value, HTTP_VALUE};
use header::shared::Charset;
/// The implied disposition of the content of the HTTP body
@@ -184,8 +184,7 @@ impl fmt::Display for ContentDisposition {
};
try!(write!(f, "'"));
try!(f.write_str(
&*percent_encoding::percent_encode(
bytes, percent_encoding::HTTP_VALUE_ENCODE_SET)))
&percent_encoding::percent_encode(bytes, HTTP_VALUE).to_string()))
}
},
DispositionParam::Ext(ref k, ref v) => try!(write!(f, "; {}=\"{}\"", k, v)),

View File

@@ -118,7 +118,7 @@ pub fn parse_extended_value(val: &str) -> ::Result<ExtendedValue> {
// Interpret the third piece as a sequence of value characters
let value: Vec<u8> = match parts.next() {
None => return Err(::Error::Header),
Some(v) => percent_encoding::percent_decode(v.as_bytes()),
Some(v) => percent_encoding::percent_decode(v.as_bytes()).collect(),
};
Ok(ExtendedValue {
@@ -128,11 +128,19 @@ pub fn parse_extended_value(val: &str) -> ::Result<ExtendedValue> {
})
}
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
pub HTTP_VALUE = [percent_encoding::SIMPLE_ENCODE_SET] | {
' ', '"', '%', '\'', '(', ')', '*', ',', '/', ':', ';', '<', '-', '>', '?',
'[', '\\', ']', '{', '}'
}
}
impl Display for ExtendedValue {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let encoded_value =
percent_encoding::percent_encode(&self.value[..],
percent_encoding::HTTP_VALUE_ENCODE_SET);
percent_encoding::percent_encode(&self.value[..], HTTP_VALUE);
if let Some(ref lang) = self.language_tag {
write!(f, "{}'{}'{}", self.charset, lang, encoded_value)
} else {