| 1113 | } |
| 1114 | |
| 1115 | fn decoded_http_body(headers: &str, body: &[u8]) -> Result<Vec<u8>, String> { |
| 1116 | if header_value(headers, "transfer-encoding").is_some_and(|value| { |
| 1117 | value |
| 1118 | .split(',') |
| 1119 | .any(|encoding| encoding.trim().eq_ignore_ascii_case("chunked")) |
| 1120 | }) { |
| 1121 | return decode_chunked_body(body); |
| 1122 | } |
| 1123 | Ok(content_length(headers) |
| 1124 | .and_then(|length| body.get(..length)) |
| 1125 | .unwrap_or(body) |
| 1126 | .to_vec()) |
| 1127 | } |
| 1128 | |
| 1129 | fn decode_chunked_body(mut body: &[u8]) -> Result<Vec<u8>, String> { |
| 1130 | let mut decoded = Vec::new(); |