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".
pull/140/head
Redrield 4 years ago
parent 006cec72ea
commit bcf2b22d9e
No known key found for this signature in database
GPG Key ID: A7A9A555EF465CBB
  1. 5
      src/handshake/server.rs

@ -89,10 +89,9 @@ pub fn create_response(request: &Request) -> Result<Response> {
fn write_response<T>(w: &mut dyn io::Write, response: &HttpResponse<T>) -> 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() {

Loading…
Cancel
Save