Skip to content

Commit

Permalink
Merge pull request #12 from PureW/master
Browse files Browse the repository at this point in the history
Query-param handling and updating of dependencies
  • Loading branch information
Nazarii Sheremet committed Nov 11, 2017
2 parents f7cc57e + 9342a00 commit 082160b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ keywords = ["rust", "http-client"]
license = "MPL-2.0"

[dependencies]
serde_json = "0.9"
serde_json = "1.0.*"
rand = "0.3"
native-tls = "0.1.4"
url = "1.4"
url = "1.6"
clippy = { version = "0.0.134", optional = true}

[features]
Expand Down
18 changes: 17 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,10 +297,14 @@ impl HTTP {
}
}

let path = match self.url.query() {
Some(q) => format!("{}?{}", self.url.path(), q),
None => self.url.path().to_string(),
};
let mut str = String::new();
str += &format!("{} {} {}{}",
self.method,
self.url.path(),
path,
HTTP_VERSION,
SEP);

Expand Down Expand Up @@ -424,3 +428,15 @@ fn organize_header(header: &HashMap<String, String>,

(data, c_type)
}

#[cfg(test)]
mod tests {
use super::HTTP;

#[test]
fn test_query_params() {
let mut http = HTTP::new("http://moo.com/?foo=bar").unwrap();
let expected = "GET /?foo=bar".to_string();
assert_eq!(http.get().create_request().unwrap()[0 .. expected.len()], expected);
}
}

0 comments on commit 082160b

Please sign in to comment.