(self, headers: HeaderMap)
| 339 | B::Error: fmt::Debug, |
| 340 | { |
| 341 | fn convert(self, headers: HeaderMap) -> BodyFuture { |
| 342 | if headers.get(CONTENT_ENCODING).is_some() { |
| 343 | return convert_to_binary(self); |
| 344 | } |
| 345 | |
| 346 | let content_type = if let Some(value) = headers.get(CONTENT_TYPE) { |
| 347 | value.to_str().unwrap_or_default() |
| 348 | } else { |
| 349 | // Content-Type and Content-Encoding not set, passthrough as utf8 text |
| 350 | return convert_to_text(self, "utf-8"); |
| 351 | }; |
| 352 | |
| 353 | for prefix in TEXT_ENCODING_PREFIXES { |
| 354 | if content_type.starts_with(prefix) { |
| 355 | return convert_to_text(self, content_type); |
| 356 | } |
| 357 | } |
| 358 | |
| 359 | for suffix in TEXT_ENCODING_SUFFIXES { |
| 360 | let mut parts = content_type.trim().split(';'); |
| 361 | let mime_type = parts.next().unwrap_or_default(); |
| 362 | if mime_type.ends_with(suffix) { |
| 363 | return convert_to_text(self, content_type); |
| 364 | } |
| 365 | } |
| 366 | |
| 367 | if let Some(value) = headers.get(X_LAMBDA_HTTP_CONTENT_ENCODING) { |
| 368 | if value == "text" { |
| 369 | return convert_to_text(self, content_type); |
| 370 | } |
| 371 | } |
| 372 | |
| 373 | convert_to_binary(self) |
| 374 | } |
| 375 | } |
| 376 | |
| 377 | fn convert_to_binary<B>(body: B) -> BodyFuture |
no test coverage detected