http: sync: drop unused &self parameter

these are just internal helpers, changing their signature is fine.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
This commit is contained in:
Fabian Grünbichler 2023-03-03 12:39:24 +01:00 committed by Wolfgang Bumiller
parent 6a1be173a6
commit 39453abb8f

View File

@ -33,11 +33,11 @@ impl Client {
Ok(builder.build()) Ok(builder.build())
} }
fn call(&self, req: ureq::Request) -> Result<ureq::Response, Error> { fn call(req: ureq::Request) -> Result<ureq::Response, Error> {
req.call().map_err(Into::into) req.call().map_err(Into::into)
} }
fn send<R>(&self, req: ureq::Request, body: R) -> Result<ureq::Response, Error> fn send<R>(req: ureq::Request, body: R) -> Result<ureq::Response, Error>
where where
R: Read, R: Read,
{ {
@ -105,7 +105,7 @@ impl HttpClient<String, String> for Client {
let req = self.agent()?.get(uri); let req = self.agent()?.get(uri);
let req = Self::add_headers(req, None, extra_headers); let req = Self::add_headers(req, None, extra_headers);
self.call(req).and_then(Self::convert_response_to_string) Self::call(req).and_then(Self::convert_response_to_string)
} }
fn post( fn post(
@ -119,8 +119,8 @@ impl HttpClient<String, String> for Client {
let req = Self::add_headers(req, content_type, extra_headers); let req = Self::add_headers(req, content_type, extra_headers);
match body { match body {
Some(body) => self.send(req, body.as_bytes()), Some(body) => Self::send(req, body.as_bytes()),
None => self.call(req), None => Self::call(req),
} }
.and_then(Self::convert_response_to_string) .and_then(Self::convert_response_to_string)
} }
@ -138,8 +138,7 @@ impl HttpClient<String, String> for Client {
} }
} }
self.send(req, request.body().as_bytes()) Self::send(req, request.body().as_bytes()).and_then(Self::convert_response_to_string)
.and_then(Self::convert_response_to_string)
} }
} }
@ -152,7 +151,7 @@ impl HttpClient<&[u8], Vec<u8>> for Client {
let req = self.agent()?.get(uri); let req = self.agent()?.get(uri);
let req = Self::add_headers(req, None, extra_headers); let req = Self::add_headers(req, None, extra_headers);
self.call(req).and_then(Self::convert_response_to_vec) Self::call(req).and_then(Self::convert_response_to_vec)
} }
fn post( fn post(
@ -166,8 +165,8 @@ impl HttpClient<&[u8], Vec<u8>> for Client {
let req = Self::add_headers(req, content_type, extra_headers); let req = Self::add_headers(req, content_type, extra_headers);
match body { match body {
Some(body) => self.send(req, body), Some(body) => Self::send(req, body),
None => self.call(req), None => Self::call(req),
} }
.and_then(Self::convert_response_to_vec) .and_then(Self::convert_response_to_vec)
} }
@ -185,8 +184,7 @@ impl HttpClient<&[u8], Vec<u8>> for Client {
} }
} }
self.send(req, *request.body()) Self::send(req, *request.body()).and_then(Self::convert_response_to_vec)
.and_then(Self::convert_response_to_vec)
} }
} }
@ -199,7 +197,7 @@ impl HttpClient<Box<dyn Read>, Box<dyn Read>> for Client {
let req = self.agent()?.get(uri); let req = self.agent()?.get(uri);
let req = Self::add_headers(req, None, extra_headers); let req = Self::add_headers(req, None, extra_headers);
self.call(req).and_then(Self::convert_response_to_reader) Self::call(req).and_then(Self::convert_response_to_reader)
} }
fn post( fn post(
@ -213,8 +211,8 @@ impl HttpClient<Box<dyn Read>, Box<dyn Read>> for Client {
let req = Self::add_headers(req, content_type, extra_headers); let req = Self::add_headers(req, content_type, extra_headers);
match body { match body {
Some(body) => self.send(req, body), Some(body) => Self::send(req, body),
None => self.call(req), None => Self::call(req),
} }
.and_then(Self::convert_response_to_reader) .and_then(Self::convert_response_to_reader)
} }
@ -234,7 +232,6 @@ impl HttpClient<Box<dyn Read>, Box<dyn Read>> for Client {
} }
} }
self.send(req, Box::new(request.body_mut())) Self::send(req, Box::new(request.body_mut())).and_then(Self::convert_response_to_reader)
.and_then(Self::convert_response_to_reader)
} }
} }