fix bug in combining query strings
This commit is contained in:
16
src/conn.rs
16
src/conn.rs
@@ -30,12 +30,7 @@ impl ConnectionPool {
|
||||
|
||||
let hostname = url.host_str().unwrap_or("localhost"); // is localhost a good alternative?
|
||||
|
||||
let query_string = match (url.query(), request.query.len() > 0) {
|
||||
(Some(urlq), true) => format!("?{}{}", urlq, request.query),
|
||||
(Some(urlq), false) => format!("?{}", urlq),
|
||||
(None, true) => format!("?{}", request.query),
|
||||
(None, false) => "".to_string(),
|
||||
};
|
||||
let query_string = combine_query(&url, &request.query);
|
||||
|
||||
let is_secure = url.scheme().eq_ignore_ascii_case("https");
|
||||
|
||||
@@ -197,3 +192,12 @@ fn match_cookies<'a>(jar: &'a CookieJar, domain: &str, path: &str, is_secure: bo
|
||||
.map(|o| o.unwrap())
|
||||
.collect()
|
||||
}
|
||||
|
||||
fn combine_query(url: &Url, query: &QString) -> String {
|
||||
match (url.query(), query.len() > 0) {
|
||||
(Some(urlq), true) => format!("?{}&{}", urlq, query),
|
||||
(Some(urlq), false) => format!("?{}", urlq),
|
||||
(None, true) => format!("?{}", query),
|
||||
(None, false) => "".to_string(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,5 +49,5 @@ fn query_in_path_and_req() {
|
||||
let vec = resp.to_write_vec();
|
||||
let s = String::from_utf8_lossy(&vec);
|
||||
println!("{}", s);
|
||||
assert!(s.contains("GET /query_in_path_and_req?foo=barbaz=1%202%203 HTTP/1.1"))
|
||||
assert!(s.contains("GET /query_in_path_and_req?foo=bar&baz=1%202%203 HTTP/1.1"))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user