Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -430,15 +430,15 @@ mod tests {
client.set_redirect_policy(RedirectPolicy::FollowAll);

let res = client.get("http://127.0.0.1").send().unwrap();
assert_eq!(res.headers.get(), Some(&Server("mock3".to_string())));
assert_eq!(res.headers.get(), Some(&Server("mock3".to_owned())));
}

#[test]
fn test_redirect_dontfollow() {
let mut client = Client::with_connector(MockRedirectPolicy);
client.set_redirect_policy(RedirectPolicy::FollowNone);
let res = client.get("http://127.0.0.1").send().unwrap();
assert_eq!(res.headers.get(), Some(&Server("mock1".to_string())));
assert_eq!(res.headers.get(), Some(&Server("mock1".to_owned())));
}

#[test]
Expand All @@ -449,7 +449,7 @@ mod tests {
let mut client = Client::with_connector(MockRedirectPolicy);
client.set_redirect_policy(RedirectPolicy::FollowIf(follow_if));
let res = client.get("http://127.0.0.1").send().unwrap();
assert_eq!(res.headers.get(), Some(&Server("mock2".to_string())));
assert_eq!(res.headers.get(), Some(&Server("mock2".to_owned())));
}

/// Tests that the `Client::set_ssl_verifier` method does not drop the
Expand Down
4 changes: 2 additions & 2 deletions src/client/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ mod tests {
None => panic!("Transfer-Encoding: chunked expected!"),
};
// The body is correct?
assert_eq!(read_to_string(res).unwrap(), "qwert".to_string());
assert_eq!(read_to_string(res).unwrap(), "qwert".to_owned());
}

/// Tests that when a chunk size is not a valid radix-16 number, an error
Expand Down Expand Up @@ -229,6 +229,6 @@ mod tests {

let res = Response::new(Box::new(stream)).unwrap();

assert_eq!(read_to_string(res).unwrap(), "1".to_string());
assert_eq!(read_to_string(res).unwrap(), "1".to_owned());
}
}
6 changes: 3 additions & 3 deletions src/header/common/accept.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ header! {
// vec![b"audio/*; q=0.2, audio/basic"],
// Some(HeaderField(vec![
// QualityItem::new(Mime(TopLevel::Audio, SubLevel::Star, vec![]), Quality(200)),
// qitem(Mime(TopLevel::Audio, SubLevel::Ext("basic".to_string()), vec![])),
// qitem(Mime(TopLevel::Audio, SubLevel::Ext("basic".to_owned()), vec![])),
// ])));
test_header!(
test2,
Expand All @@ -49,9 +49,9 @@ header! {
QualityItem::new(Mime(TopLevel::Text, SubLevel::Plain, vec![]), Quality(500)),
qitem(Mime(TopLevel::Text, SubLevel::Html, vec![])),
QualityItem::new(
Mime(TopLevel::Text, SubLevel::Ext("x-dvi".to_string()), vec![]),
Mime(TopLevel::Text, SubLevel::Ext("x-dvi".to_owned()), vec![]),
Quality(800)),
qitem(Mime(TopLevel::Text, SubLevel::Ext("x-c".to_string()), vec![])),
qitem(Mime(TopLevel::Text, SubLevel::Ext("x-c".to_owned()), vec![])),
])));
// Custom tests
test_header!(
Expand Down
6 changes: 3 additions & 3 deletions src/header/common/accept_language.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ header! {
test_header!(
test2, vec![b"en-us, en; q=0.5, fr"],
Some(AcceptLanguage(vec![
qitem(Language {primary: "en".to_string(), sub: Some("us".to_string())}),
QualityItem::new(Language{primary: "en".to_string(), sub: None}, Quality(500)),
qitem(Language {primary: "fr".to_string(), sub: None}),
qitem(Language {primary: "en".to_owned(), sub: Some("us".to_owned())}),
QualityItem::new(Language{primary: "en".to_owned(), sub: None}, Quality(500)),
qitem(Language {primary: "fr".to_owned(), sub: None}),
])));
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/header/common/accept_ranges.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ impl FromStr for RangeUnit {
"bytes" => Ok(RangeUnit::Bytes),
"none" => Ok(RangeUnit::None),
// FIXME: Check if s is really a Token
_ => Ok(RangeUnit::Unregistered(s.to_string())),
_ => Ok(RangeUnit::Unregistered(s.to_owned())),
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/header/common/access_control_allow_origin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ impl Header for AccessControlAllowOrigin {
b"*" => Some(AccessControlAllowOrigin::Any),
b"null" => Some(AccessControlAllowOrigin::Null),
r => if let Ok(s) = str::from_utf8(r) {
Url::parse(s).ok().map(|url| AccessControlAllowOrigin::Value(url))
Url::parse(s).ok().map(AccessControlAllowOrigin::Value)
} else { None }
}
} else { None }
Expand Down
2 changes: 1 addition & 1 deletion src/header/common/allow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ header! {
Method::Trace,
Method::Connect,
Method::Patch,
Method::Extension("fOObAr".to_string())])));
Method::Extension("fOObAr".to_owned())])));
test_header!(
test3,
vec![b""],
Expand Down
20 changes: 10 additions & 10 deletions src/header/common/authorization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,11 @@ impl FromStr for Basic {
Ok(text) => {
let mut parts = &mut text.split(':');
let user = match parts.next() {
Some(part) => part.to_string(),
Some(part) => part.to_owned(),
None => return Err(())
};
let password = match parts.next() {
Some(part) => Some(part.to_string()),
Some(part) => Some(part.to_owned()),
None => None
};
Ok(Basic {
Expand Down Expand Up @@ -161,8 +161,8 @@ mod tests {
#[test]
fn test_raw_auth() {
let mut headers = Headers::new();
headers.set(Authorization("foo bar baz".to_string()));
assert_eq!(headers.to_string(), "Authorization: foo bar baz\r\n".to_string());
headers.set(Authorization("foo bar baz".to_owned()));
assert_eq!(headers.to_string(), "Authorization: foo bar baz\r\n".to_owned());
}

#[test]
Expand All @@ -176,33 +176,33 @@ mod tests {
fn test_basic_auth() {
let mut headers = Headers::new();
headers.set(Authorization(
Basic { username: "Aladdin".to_string(), password: Some("open sesame".to_string()) }));
Basic { username: "Aladdin".to_owned(), password: Some("open sesame".to_owned()) }));
assert_eq!(
headers.to_string(),
"Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==\r\n".to_string());
"Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==\r\n".to_owned());
}

#[test]
fn test_basic_auth_no_password() {
let mut headers = Headers::new();
headers.set(Authorization(Basic { username: "Aladdin".to_string(), password: None }));
assert_eq!(headers.to_string(), "Authorization: Basic QWxhZGRpbjo=\r\n".to_string());
headers.set(Authorization(Basic { username: "Aladdin".to_owned(), password: None }));
assert_eq!(headers.to_string(), "Authorization: Basic QWxhZGRpbjo=\r\n".to_owned());
}

#[test]
fn test_basic_auth_parse() {
let auth: Authorization<Basic> = Header::parse_header(
&[b"Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==".to_vec()]).unwrap();
assert_eq!(auth.0.username, "Aladdin");
assert_eq!(auth.0.password, Some("open sesame".to_string()));
assert_eq!(auth.0.password, Some("open sesame".to_owned()));
}

#[test]
fn test_basic_auth_parse_no_password() {
let auth: Authorization<Basic> = Header::parse_header(
&[b"Basic QWxhZGRpbjo=".to_vec()]).unwrap();
assert_eq!(auth.0.username, "Aladdin");
assert_eq!(auth.0.password, Some("".to_string()));
assert_eq!(auth.0.password, Some("".to_owned()));
}

}
Expand Down
18 changes: 9 additions & 9 deletions src/header/common/cache_control.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,15 @@ impl FromStr for CacheDirective {
"proxy-revalidate" => Ok(ProxyRevalidate),
"" => Err(None),
_ => match s.find('=') {
Some(idx) if idx+1 < s.len() => match (&s[..idx], &s[idx+1..].trim_matches('"')) {
("max-age" , secs) => secs.parse().map(MaxAge).map_err(|x| Some(x)),
("max-stale", secs) => secs.parse().map(MaxStale).map_err(|x| Some(x)),
("min-fresh", secs) => secs.parse().map(MinFresh).map_err(|x| Some(x)),
("s-maxage", secs) => secs.parse().map(SMaxAge).map_err(|x| Some(x)),
(left, right) => Ok(Extension(left.to_string(), Some(right.to_string())))
Some(idx) if idx+1 < s.len() => match (&s[..idx], (&s[idx+1..]).trim_matches('"')) {
("max-age" , secs) => secs.parse().map(MaxAge).map_err(Some),
("max-stale", secs) => secs.parse().map(MaxStale).map_err(Some),
("min-fresh", secs) => secs.parse().map(MinFresh).map_err(Some),
("s-maxage", secs) => secs.parse().map(SMaxAge).map_err(Some),
(left, right) => Ok(Extension(left.to_owned(), Some(right.to_owned())))
},
Some(_) => Err(None),
None => Ok(Extension(s.to_string(), None))
None => Ok(Extension(s.to_owned(), None))
}
}
}
Expand Down Expand Up @@ -169,8 +169,8 @@ mod tests {
fn test_parse_extension() {
let cache = Header::parse_header(&[b"foo, bar=baz".to_vec()]);
assert_eq!(cache, Some(CacheControl(vec![
CacheDirective::Extension("foo".to_string(), None),
CacheDirective::Extension("bar".to_string(), Some("baz".to_string()))])))
CacheDirective::Extension("foo".to_owned(), None),
CacheDirective::Extension("bar".to_owned(), Some("baz".to_owned()))])))
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion src/header/common/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ impl FromStr for ConnectionOption {
match s {
"keep-alive" => Ok(KeepAlive),
"close" => Ok(Close),
s => Ok(ConnectionHeader(UniCase(s.to_string())))
s => Ok(ConnectionHeader(UniCase(s.to_owned())))
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/header/common/content_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ header! {
Some(HeaderField(Mime(
TopLevel::Text,
SubLevel::Html,
vec![(Attr::Charset, Value::Ext("iso-8859-4".to_string()))]))));
vec![(Attr::Charset, Value::Ext("iso-8859-4".to_owned()))]))));
}
}

Expand Down
12 changes: 6 additions & 6 deletions src/header/common/cookie.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,21 +86,21 @@ impl Cookie {
#[test]
fn test_parse() {
let h = Header::parse_header(&[b"foo=bar; baz=quux".to_vec()][..]);
let c1 = CookiePair::new("foo".to_string(), "bar".to_string());
let c2 = CookiePair::new("baz".to_string(), "quux".to_string());
let c1 = CookiePair::new("foo".to_owned(), "bar".to_owned());
let c2 = CookiePair::new("baz".to_owned(), "quux".to_owned());
assert_eq!(h, Some(Cookie(vec![c1, c2])));
}

#[test]
fn test_fmt() {
use header::Headers;

let mut cookie_pair = CookiePair::new("foo".to_string(), "bar".to_string());
let mut cookie_pair = CookiePair::new("foo".to_owned(), "bar".to_owned());
cookie_pair.httponly = true;
cookie_pair.path = Some("/p".to_string());
cookie_pair.path = Some("/p".to_owned());
let cookie_header = Cookie(vec![
cookie_pair,
CookiePair::new("baz".to_string(),"quux".to_string())]);
CookiePair::new("baz".to_owned(),"quux".to_owned())]);
let mut headers = Headers::new();
headers.set(cookie_header);

Expand All @@ -109,7 +109,7 @@ fn test_fmt() {

#[test]
fn cookie_jar() {
let cookie_pair = CookiePair::new("foo".to_string(), "bar".to_string());
let cookie_pair = CookiePair::new("foo".to_owned(), "bar".to_owned());
let cookie_header = Cookie(vec![cookie_pair]);
let jar = cookie_header.to_cookie_jar(&[]);
let new_cookie_header = Cookie::from_cookie_jar(&jar);
Expand Down
16 changes: 8 additions & 8 deletions src/header/common/etag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,29 +28,29 @@ header! {
// From the RFC
test_header!(test1,
vec![b"\"xyzzy\""],
Some(ETag(EntityTag::new(false, "xyzzy".to_string()))));
Some(ETag(EntityTag::new(false, "xyzzy".to_owned()))));
test_header!(test2,
vec![b"W/\"xyzzy\""],
Some(ETag(EntityTag::new(true, "xyzzy".to_string()))));
Some(ETag(EntityTag::new(true, "xyzzy".to_owned()))));
test_header!(test3,
vec![b"\"\""],
Some(ETag(EntityTag::new(false, "".to_string()))));
Some(ETag(EntityTag::new(false, "".to_owned()))));
// Own tests
test_header!(test4,
vec![b"\"foobar\""],
Some(ETag(EntityTag::new(false, "foobar".to_string()))));
Some(ETag(EntityTag::new(false, "foobar".to_owned()))));
test_header!(test5,
vec![b"\"\""],
Some(ETag(EntityTag::new(false, "".to_string()))));
Some(ETag(EntityTag::new(false, "".to_owned()))));
test_header!(test6,
vec![b"W/\"weak-etag\""],
Some(ETag(EntityTag::new(true, "weak-etag".to_string()))));
Some(ETag(EntityTag::new(true, "weak-etag".to_owned()))));
test_header!(test7,
vec![b"W/\"\x65\x62\""],
Some(ETag(EntityTag::new(true, "\u{0065}\u{0062}".to_string()))));
Some(ETag(EntityTag::new(true, "\u{0065}\u{0062}".to_owned()))));
test_header!(test8,
vec![b"W/\"\""],
Some(ETag(EntityTag::new(true, "".to_string()))));
Some(ETag(EntityTag::new(true, "".to_owned()))));
test_header!(test9,
vec![b"no-dquotes"],
None::<ETag>);
Expand Down
4 changes: 2 additions & 2 deletions src/header/common/host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,14 @@ mod tests {
fn test_host() {
let host = Header::parse_header([b"foo.com".to_vec()].as_ref());
assert_eq!(host, Some(Host {
hostname: "foo.com".to_string(),
hostname: "foo.com".to_owned(),
port: None
}));


let host = Header::parse_header([b"foo.com:8080".to_vec()].as_ref());
assert_eq!(host, Some(Host {
hostname: "foo.com".to_string(),
hostname: "foo.com".to_owned(),
port: Some(8080)
}));
}
Expand Down
8 changes: 4 additions & 4 deletions src/header/common/if_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ header! {
test1,
vec![b"\"xyzzy\""],
Some(HeaderField::Items(
vec![EntityTag::new(false, "xyzzy".to_string())])));
vec![EntityTag::new(false, "xyzzy".to_owned())])));
test_header!(
test2,
vec![b"\"xyzzy\", \"r2d2xxxx\", \"c3piozzzz\""],
Some(HeaderField::Items(
vec![EntityTag::new(false, "xyzzy".to_string()),
EntityTag::new(false, "r2d2xxxx".to_string()),
EntityTag::new(false, "c3piozzzz".to_string())])));
vec![EntityTag::new(false, "xyzzy".to_owned()),
EntityTag::new(false, "r2d2xxxx".to_owned()),
EntityTag::new(false, "c3piozzzz".to_owned())])));
test_header!(test3, vec![b"*"], Some(IfMatch::Any));
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/header/common/if_none_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ mod tests {

if_none_match = Header::parse_header([b"\"foobar\", W/\"weak-etag\"".to_vec()].as_ref());
let mut entities: Vec<EntityTag> = Vec::new();
let foobar_etag = EntityTag::new(false, "foobar".to_string());
let weak_etag = EntityTag::new(true, "weak-etag".to_string());
let foobar_etag = EntityTag::new(false, "foobar".to_owned());
let weak_etag = EntityTag::new(true, "weak-etag".to_owned());
entities.push(foobar_etag);
entities.push(weak_etag);
assert_eq!(if_none_match, Some(IfNoneMatch::Items(entities)));
Expand Down
4 changes: 2 additions & 2 deletions src/header/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,12 @@ macro_rules! test_header {
let result_cmp: Vec<String> = result
.to_ascii_lowercase()
.split(' ')
.map(|x| x.to_string())
.map(|x| x.to_owned())
.collect();
let expected_cmp: Vec<String> = expected
.to_ascii_lowercase()
.split(' ')
.map(|x| x.to_string())
.map(|x| x.to_owned())
.collect();
assert_eq!(result_cmp.concat(), expected_cmp.concat());
}
Expand Down
2 changes: 1 addition & 1 deletion src/header/common/pragma.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ fn test_parse_header() {
let b = Pragma::NoCache;
assert_eq!(a, b);
let c: Pragma = Header::parse_header([b"FoObar".to_vec()].as_ref()).unwrap();
let d = Pragma::Ext("FoObar".to_string());
let d = Pragma::Ext("FoObar".to_owned());
assert_eq!(c, d);
let e: Option<Pragma> = Header::parse_header([b"".to_vec()].as_ref());
assert_eq!(e, None);
Expand Down
10 changes: 5 additions & 5 deletions src/header/common/set_cookie.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ impl SetCookie {
#[test]
fn test_parse() {
let h = Header::parse_header(&[b"foo=bar; HttpOnly".to_vec()][..]);
let mut c1 = Cookie::new("foo".to_string(), "bar".to_string());
let mut c1 = Cookie::new("foo".to_owned(), "bar".to_owned());
c1.httponly = true;

assert_eq!(h, Some(SetCookie(vec![c1])));
Expand All @@ -127,10 +127,10 @@ fn test_parse() {
fn test_fmt() {
use header::Headers;

let mut cookie = Cookie::new("foo".to_string(), "bar".to_string());
let mut cookie = Cookie::new("foo".to_owned(), "bar".to_owned());
cookie.httponly = true;
cookie.path = Some("/p".to_string());
let cookies = SetCookie(vec![cookie, Cookie::new("baz".to_string(), "quux".to_string())]);
cookie.path = Some("/p".to_owned());
let cookies = SetCookie(vec![cookie, Cookie::new("baz".to_owned(), "quux".to_owned())]);
let mut headers = Headers::new();
headers.set(cookies);

Expand All @@ -142,7 +142,7 @@ fn test_fmt() {
#[test]
fn cookie_jar() {
let jar = CookieJar::new(b"secret");
let cookie = Cookie::new("foo".to_string(), "bar".to_string());
let cookie = Cookie::new("foo".to_owned(), "bar".to_owned());
jar.encrypted().add(cookie);

let cookies = SetCookie::from_cookie_jar(&jar);
Expand Down
Loading