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