Send a pre-built HTTP request and return status + body bytes.
(
&self,
req: Request<Full<Bytes>>,
timeout: Duration,
)
| 315 | |
| 316 | /// Send a pre-built HTTP request and return status + body bytes. |
| 317 | async fn send_request( |
| 318 | &self, |
| 319 | req: Request<Full<Bytes>>, |
| 320 | timeout: Duration, |
| 321 | ) -> Result<(hyper::StatusCode, Bytes), PodmanApiError> { |
| 322 | let mut sender = self.connect().await?; |
| 323 | let response = tokio::time::timeout(timeout, sender.send_request(req)) |
| 324 | .await |
| 325 | .map_err(|_| PodmanApiError::Timeout(timeout))? |
| 326 | .map_err(|e| PodmanApiError::Connection(e.to_string()))?; |
| 327 | let status = response.status(); |
| 328 | let bytes = tokio::time::timeout(timeout, response.into_body().collect()) |
| 329 | .await |
| 330 | .map_err(|_| PodmanApiError::Timeout(timeout))? |
| 331 | .map_err(|e| PodmanApiError::Connection(e.to_string()))? |
| 332 | .to_bytes(); |
| 333 | Ok((status, bytes)) |
| 334 | } |
| 335 | |
| 336 | /// Perform a versioned HTTP request and return status + body bytes. |
| 337 | async fn request( |