[pbs-devel] [PATCH v2 backup 16/27] tools/http: add request_with_agent helper
Dietmar Maurer
dietmar at proxmox.com
Wed Apr 28 12:38:15 CEST 2021
replaced by my own cleanup patch
On 4/22/21 4:02 PM, Wolfgang Bumiller wrote:
> Signed-off-by: Wolfgang Bumiller <w.bumiller at proxmox.com>
> ---
> src/tools/http.rs | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/src/tools/http.rs b/src/tools/http.rs
> index 31dea33a..55c8e41e 100644
> --- a/src/tools/http.rs
> +++ b/src/tools/http.rs
> @@ -60,6 +60,15 @@ impl SimpleHttp {
> Self { client }
> }
>
> + /// Helper to finish a request with our user agent string and perform the request:
> + pub async fn request_with_agent(
> + &mut self,
> + request: http::request::Builder,
> + body: Body,
> + ) -> Result<Response<Body>, Error> {
> + self.request(request.header("User-Agent", USER_AGENT_STRING).body(body)?).await
> + }
> +
> pub async fn request(&self, request: Request<Body>) -> Result<Response<Body>, Error> {
> self.client.request(request)
> .map_err(Error::from)
More information about the pbs-devel
mailing list