src/client/http_client.rs: code cleanup
This commit is contained in:
parent
6ab34afa88
commit
d2c48afc6e
@ -330,18 +330,11 @@ impl HttpClient {
|
|||||||
Box::new(login_future)
|
Box::new(login_future)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn api_request(
|
fn api_response(response: Response<Body>) -> impl Future<Item=Value, Error=Error> {
|
||||||
client: Client<hyper_tls::HttpsConnector<hyper::client::HttpConnector>>,
|
|
||||||
req: Request<Body>
|
|
||||||
) -> impl Future<Item=Value, Error=Error> {
|
|
||||||
|
|
||||||
client.request(req)
|
let status = response.status();
|
||||||
.map_err(Error::from)
|
|
||||||
.and_then(|resp| {
|
|
||||||
|
|
||||||
let status = resp.status();
|
response
|
||||||
|
|
||||||
resp
|
|
||||||
.into_body()
|
.into_body()
|
||||||
.concat2()
|
.concat2()
|
||||||
.map_err(Error::from)
|
.map_err(Error::from)
|
||||||
@ -359,7 +352,16 @@ impl HttpClient {
|
|||||||
bail!("HTTP Error {}: {}", status, text);
|
bail!("HTTP Error {}: {}", status, text);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
}
|
||||||
|
|
||||||
|
fn api_request(
|
||||||
|
client: Client<hyper_tls::HttpsConnector<hyper::client::HttpConnector>>,
|
||||||
|
req: Request<Body>
|
||||||
|
) -> impl Future<Item=Value, Error=Error> {
|
||||||
|
|
||||||
|
client.request(req)
|
||||||
|
.map_err(Error::from)
|
||||||
|
.and_then(Self::api_response)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn request_builder(server: &str, method: &str, path: &str, data: Option<Value>) -> Result<Request<Body>, Error> {
|
pub fn request_builder(server: &str, method: &str, path: &str, data: Option<Value>) -> Result<Request<Body>, Error> {
|
||||||
@ -550,7 +552,7 @@ impl BackupClient {
|
|||||||
|
|
||||||
//upload_pxar(h2, known_chunks, &dir_path, wid).unwrap()
|
//upload_pxar(h2, known_chunks, &dir_path, wid).unwrap()
|
||||||
Self::upload_stream(h2_3, wid, stream, known_chunks.clone())
|
Self::upload_stream(h2_3, wid, stream, known_chunks.clone())
|
||||||
.and_then(move |size| {
|
.and_then(move |_size| {
|
||||||
Self::h2post(h2_4, "dynamic_close", Some(json!({ "wid": wid })))
|
Self::h2post(h2_4, "dynamic_close", Some(json!({ "wid": wid })))
|
||||||
})
|
})
|
||||||
.map(|_| ())
|
.map(|_| ())
|
||||||
|
Loading…
Reference in New Issue
Block a user