diff --git a/src/main.rs b/src/main.rs index 19fc6f2..d9441c3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -240,11 +240,18 @@ impl Response { fn headers (&self) -> Vec { match self { - Self::TextPlain(text, enc) => vec![ - f!("Content-Type: text/plain"), - format!("Content-Length: {}", text.len()), - enc.header().to_string(), - ], + Self::TextPlain(text, enc) => { + let mut v = vec![ + f!("Content-Type: text/plain"), + format!("Content-Length: {}", text.len()), + ]; + + 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())