From 5cf846876dfeab846d48df215074cae0e4932055 Mon Sep 17 00:00:00 2001 From: Holger Rapp Date: Sun, 15 Jan 2017 12:33:41 +0000 Subject: [PATCH] Port to hyper 0.10. --- Cargo.toml | 2 +- src/hurl/hyper.rs | 15 +++++---------- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index bf3383e2..ae0356d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,5 +15,5 @@ default = ["http"] http = ["hyper"] [dependencies] -hyper = { version = "0.6.8", optional = true } +hyper = { version = "^0.10.0", optional = true } log = "0.3.1" diff --git a/src/hurl/hyper.rs b/src/hurl/hyper.rs index 654c04f..24bde3c 100644 --- a/src/hurl/hyper.rs +++ b/src/hurl/hyper.rs @@ -58,14 +58,7 @@ impl Hurl for HyperHurl { match req.query { Some(ref query) => { // if any existing pairs - let existing: Vec<(String, String)> = match url.query_pairs() { - Some(ref existing) => { - existing.clone() - } - _ => { - Vec::new() - } - }; + let existing: Vec<(String, String)> = url.query_pairs().map(|(a,b)| (a.to_string(), b.to_string())).collect(); // final pairs let mut pairs: Vec<(&str, &str)> = Vec::new(); @@ -81,7 +74,9 @@ impl Hurl for HyperHurl { } // set new pairs - url.set_query_from_pairs(pairs.into_iter()); + url.query_pairs_mut().clear().extend_pairs( + pairs.iter().map(|&(k, v)| { (&k[..], &v[..]) }) + ); } _ => {} }; @@ -113,4 +108,4 @@ impl Hurl for HyperHurl { } } } -} \ No newline at end of file +}