convert RequestBuilder to a &mut Self builder

Closes #108
This commit is contained in:
Sean McArthur
2017-06-01 16:10:26 -07:00
parent 546880cea9
commit e176dcebca
4 changed files with 500 additions and 452 deletions

View File

@@ -86,7 +86,10 @@ fn test_redirect_301_and_302_and_303_changes_post_to_get() {
let url = format!("http://{}/{}", redirect.addr(), code);
let dst = format!("http://{}/{}", redirect.addr(), "dst");
let res = client.post(&url).send().unwrap();
let res = client.post(&url)
.unwrap()
.send()
.unwrap();
assert_eq!(res.url().as_str(), dst);
assert_eq!(res.status(), &reqwest::StatusCode::Ok);
assert_eq!(res.headers().get(),
@@ -140,7 +143,11 @@ fn test_redirect_307_and_308_tries_to_post_again() {
let url = format!("http://{}/{}", redirect.addr(), code);
let dst = format!("http://{}/{}", redirect.addr(), "dst");
let res = client.post(&url).body("Hello").send().unwrap();
let res = client.post(&url)
.unwrap()
.body("Hello")
.send()
.unwrap();
assert_eq!(res.url().as_str(), dst);
assert_eq!(res.status(), &reqwest::StatusCode::Ok);
assert_eq!(res.headers().get(),
@@ -179,6 +186,7 @@ fn test_redirect_307_does_not_try_if_reader_cannot_reset() {
let url = format!("http://{}/{}", redirect.addr(), code);
let res = client
.post(&url)
.unwrap()
.body(reqwest::Body::new(&b"Hello"[..]))
.send()
.unwrap();
@@ -231,6 +239,7 @@ fn test_redirect_removes_sensitive_headers() {
.build()
.unwrap()
.get(&format!("http://{}/sensitive", mid_server.addr()))
.unwrap()
.header(reqwest::header::Cookie(vec![String::from("foo=bar")]))
.send()
.unwrap();
@@ -288,6 +297,7 @@ fn test_redirect_policy_can_stop_redirects_without_an_error() {
.build()
.unwrap()
.get(&url)
.unwrap()
.send()
.unwrap();
@@ -337,6 +347,7 @@ fn test_referer_is_not_set_if_disabled() {
.build().unwrap()
//client
.get(&format!("http://{}/no-refer", server.addr()))
.unwrap()
.send()
.unwrap();
}
@@ -363,6 +374,7 @@ fn test_accept_header_is_not_changed_if_set() {
let res = client
.get(&format!("http://{}/accept", server.addr()))
.unwrap()
.header(reqwest::header::Accept::json())
.send()
.unwrap();
@@ -391,6 +403,7 @@ fn test_accept_encoding_header_is_not_changed_if_set() {
let client = reqwest::Client::new().unwrap();
let res = client.get(&format!("http://{}/accept-encoding", server.addr()))
.unwrap()
.header(reqwest::header::AcceptEncoding(
vec![reqwest::header::qitem(reqwest::header::Encoding::Identity)]
))
@@ -463,6 +476,7 @@ fn test_gzip_empty_body() {
let client = reqwest::Client::new().unwrap();
let mut res = client
.head(&format!("http://{}/gzip", server.addr()))
.unwrap()
.send()
.unwrap();