http compressions stage 1 attempt 3

This commit is contained in:
YK 2024-05-11 04:31:48 +03:00
parent 35001306fb
commit 38ded8a8c3

View File

@ -240,11 +240,18 @@ impl Response {
fn headers (&self) -> Vec<String> {
match self {
Self::TextPlain(text, enc) => vec![
Self::TextPlain(text, enc) => {
let mut v = vec![
f!("Content-Type: text/plain"),
format!("Content-Length: {}", text.len()),
enc.header().to_string(),
],
];
let enc = enc.header();
if !enc.is_empty() { v.push(enc.to_string()) }
v
},
Self::OctetStream(bytes) => vec![
f!("Content-Type: application/octet-stream"),
format!("Content-Length: {}", bytes.len())