From bcf2b22d9e24f67cfff3796feb0ed9fb5be9323d Mon Sep 17 00:00:00 2001 From: Redrield Date: Sat, 12 Sep 2020 22:41:39 -0400 Subject: [PATCH] Deduplicate the reason line in HTTP responses The impl of Display for StatusCode already includes the canonical reason if it exists. The current implementation duplicates this (e.g. the status line will read "101 Switching Protocols Switching Protocols", or "400 Bad Request Bad Request". --- src/handshake/server.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/handshake/server.rs b/src/handshake/server.rs index 4cf47d1..9412a6f 100644 --- a/src/handshake/server.rs +++ b/src/handshake/server.rs @@ -89,10 +89,9 @@ pub fn create_response(request: &Request) -> Result { fn write_response(w: &mut dyn io::Write, response: &HttpResponse) -> Result<()> { writeln!( w, - "{version:?} {status} {reason}\r", + "{version:?} {status}\r", version = response.version(), - status = response.status(), - reason = response.status().canonical_reason().unwrap_or(""), + status = response.status() )?; for (k, v) in response.headers() {