Perform a versioned HTTP request and return status + body bytes.
(
&self,
method: hyper::Method,
path: &str,
body: Option<&Value>,
timeout: Duration,
)
| 335 | |
| 336 | /// Perform a versioned HTTP request and return status + body bytes. |
| 337 | async fn request( |
| 338 | &self, |
| 339 | method: hyper::Method, |
| 340 | path: &str, |
| 341 | body: Option<&Value>, |
| 342 | timeout: Duration, |
| 343 | ) -> Result<(hyper::StatusCode, Bytes), PodmanApiError> { |
| 344 | let (full_body, content_type) = match body { |
| 345 | Some(json) => { |
| 346 | let payload = |
| 347 | serde_json::to_vec(json).map_err(|e| PodmanApiError::Json(e.to_string()))?; |
| 348 | (Full::new(Bytes::from(payload)), Some("application/json")) |
| 349 | } |
| 350 | None => (Full::new(Bytes::new()), None), |
| 351 | }; |
| 352 | let req = Self::build_request( |
| 353 | method, |
| 354 | &format!("/{API_VERSION}{path}"), |
| 355 | full_body, |
| 356 | content_type, |
| 357 | ); |
| 358 | self.send_request(req, timeout).await |
| 359 | } |
| 360 | |
| 361 | /// Perform a request and deserialize the JSON response. |
| 362 | async fn request_json<T: DeserializeOwned>( |