rust-afterburn/0004-retry-client-move-URL-parsing-into-helper-function.patch
2023-03-20 20:46:22 -04:00

55 lines
1.7 KiB
Diff

From feda37277c361a29a67ab2549f8fe292c35429dd Mon Sep 17 00:00:00 2001
From: Benjamin Gilbert <bgilbert@redhat.com>
Date: Sun, 19 Mar 2023 23:55:38 -0400
Subject: [PATCH 4/6] retry/client: move URL parsing into helper function
---
src/retry/client.rs | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/src/retry/client.rs b/src/retry/client.rs
index a94c4ec7f09b..e113fe4bc69a 100644
--- a/src/retry/client.rs
+++ b/src/retry/client.rs
@@ -213,7 +213,7 @@ where
where
T: for<'de> serde::Deserialize<'de>,
{
- let url = reqwest::Url::parse(self.url.as_str()).context("failed to parse uri")?;
+ let url = self.parse_url()?;
let mut req = blocking::Request::new(Method::GET, url);
req.headers_mut().extend(self.headers.clone().into_iter());
@@ -227,7 +227,7 @@ where
where
T: for<'de> serde::Deserialize<'de>,
{
- let url = reqwest::Url::parse(self.url.as_str()).context("failed to parse uri")?;
+ let url = self.parse_url()?;
self.retry.clone().retry(|attempt| {
let mut builder = blocking::Client::new()
@@ -254,7 +254,7 @@ where
}
pub fn dispatch_post(self) -> Result<reqwest::StatusCode> {
- let url = reqwest::Url::parse(self.url.as_str()).context("failed to parse uri")?;
+ let url = self.parse_url()?;
self.retry.clone().retry(|attempt| {
let mut builder = blocking::Client::new()
@@ -308,6 +308,10 @@ where
}
}
}
+
+ fn parse_url(&self) -> Result<reqwest::Url> {
+ reqwest::Url::parse(self.url.as_str()).context("failed to parse uri")
+ }
}
/// Reqwests Request struct doesn't implement `Clone`,
--
2.39.2