Drop redundant raw bytes for text-like responses and recompute cached metadata.
(&mut self)
| 338 | ( |
| 339 | String::from_utf8_lossy(&body_bytes).into_owned(), |
| 340 | Bytes::new(), |
| 341 | ) |
| 342 | } else { |
| 343 | (String::new(), body_bytes) |
| 344 | }; |
| 345 | |
| 346 | let mut response = Self { |
| 347 | status_code, |
| 348 | status_text, |
| 349 | headers, |
| 350 | request_headers: HashMap::new(), |
| 351 | request_url: String::new(), |
| 352 | payload: ResponsePayload { |
| 353 | body: Arc::from(body), |
| 354 | body_bytes: stored_body_bytes, |
| 355 | ..ResponsePayload::default() |
| 356 | }, |
| 357 | body_size_bytes, |
| 358 | duration_ms, |
| 359 | content_type, |
| 360 | }; |
| 361 | response.compact_storage(); |
| 362 | response |
| 363 | } |
| 364 | |
| 365 | pub fn with_request_meta( |
| 366 | mut self, |
| 367 | url: impl Into<String>, |
| 368 | request_headers: HashMap<String, String>, |
| 369 | ) -> Self { |
| 370 | self.request_url = url.into(); |
| 371 | self.request_headers = request_headers; |
| 372 | self |
no test coverage detected