From 1ec60e1c15891bd71ffcea36f0d0b16babbac362 Mon Sep 17 00:00:00 2001 From: Jon Gjengset Date: Fri, 1 Oct 2021 14:08:21 -0700 Subject: [PATCH] Remove trailing newline from testing response The newline becomes part of the response body, even though it was not passed in as `body`, which makes `Response::new` difficult to use with anything that checksums data contents for example. Arguably there should also be a mechanism for passing in `[u8]` bodies, but that's for a separate feature request. --- src/response.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/response.rs b/src/response.rs index 1f7fc15..b635a95 100644 --- a/src/response.rs +++ b/src/response.rs @@ -109,7 +109,7 @@ impl Response { /// # } /// ``` pub fn new(status: u16, status_text: &str, body: &str) -> Result { - let r = format!("HTTP/1.1 {} {}\r\n\r\n{}\n", status, status_text, body); + let r = format!("HTTP/1.1 {} {}\r\n\r\n{}", status, status_text, body); (r.as_ref() as &str).parse() }