diff --git a/src/client/request.rs b/src/client/request.rs index c3954c78..79bbd249 100644 --- a/src/client/request.rs +++ b/src/client/request.rs @@ -259,11 +259,11 @@ impl ClientRequest { impl fmt::Debug for ClientRequest { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - let res = write!(f, "\nClientRequest {:?} {}:{}\n", + let res = writeln!(f, "\nClientRequest {:?} {}:{}", self.version, self.method, self.uri); - let _ = write!(f, " headers:\n"); + let _ = writeln!(f, " headers:"); for (key, val) in self.headers.iter() { - let _ = write!(f, " {:?}: {:?}\n", key, val); + let _ = writeln!(f, " {:?}: {:?}", key, val); } res } @@ -671,11 +671,11 @@ fn parts<'a>(parts: &'a mut Option, err: &Option) impl fmt::Debug for ClientRequestBuilder { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { if let Some(ref parts) = self.request { - let res = write!(f, "\nClientRequestBuilder {:?} {}:{}\n", - parts.version, parts.method, parts.uri); - let _ = write!(f, " headers:\n"); + let res = writeln!(f, "\nClientRequestBuilder {:?} {}:{}", + parts.version, parts.method, parts.uri); + let _ = writeln!(f, " headers:"); for (key, val) in parts.headers.iter() { - let _ = write!(f, " {:?}: {:?}\n", key, val); + let _ = writeln!(f, " {:?}: {:?}", key, val); } res } else { diff --git a/src/client/response.rs b/src/client/response.rs index 1a82d64b..a0ecb8a6 100644 --- a/src/client/response.rs +++ b/src/client/response.rs @@ -106,11 +106,11 @@ impl ClientResponse { impl fmt::Debug for ClientResponse { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - let res = write!( - f, "\nClientResponse {:?} {}\n", self.version(), self.status()); - let _ = write!(f, " headers:\n"); + let res = writeln!( + f, "\nClientResponse {:?} {}", self.version(), self.status()); + let _ = writeln!(f, " headers:"); for (key, val) in self.headers().iter() { - let _ = write!(f, " {:?}: {:?}\n", key, val); + let _ = writeln!(f, " {:?}: {:?}", key, val); } res } diff --git a/src/client/writer.rs b/src/client/writer.rs index cd50359c..d1c4bb22 100644 --- a/src/client/writer.rs +++ b/src/client/writer.rs @@ -105,10 +105,10 @@ impl HttpClientWriter { // render message { // status line - write!(self.buffer, "{} {} {:?}\r\n", - msg.method(), - msg.uri().path_and_query().map(|u| u.as_str()).unwrap_or("/"), - msg.version())?; + writeln!(self.buffer, "{} {} {:?}\r", + msg.method(), + msg.uri().path_and_query().map(|u| u.as_str()).unwrap_or("/"), + msg.version())?; // write headers let mut buffer = self.buffer.get_mut(); diff --git a/src/httprequest.rs b/src/httprequest.rs index 8077ab23..9d8c39b4 100644 --- a/src/httprequest.rs +++ b/src/httprequest.rs @@ -555,17 +555,17 @@ impl AsyncRead for HttpRequest {} impl fmt::Debug for HttpRequest { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - let res = write!(f, "\nHttpRequest {:?} {}:{}\n", + let res = writeln!(f, "\nHttpRequest {:?} {}:{}", self.as_ref().version, self.as_ref().method, self.path_decoded()); if !self.query_string().is_empty() { - let _ = write!(f, " query: ?{:?}\n", self.query_string()); + let _ = writeln!(f, " query: ?{:?}", self.query_string()); } if !self.match_info().is_empty() { - let _ = write!(f, " params: {:?}\n", self.as_ref().params); + let _ = writeln!(f, " params: {:?}", self.as_ref().params); } - let _ = write!(f, " headers:\n"); + let _ = writeln!(f, " headers:"); for (key, val) in self.as_ref().headers.iter() { - let _ = write!(f, " {:?}: {:?}\n", key, val); + let _ = writeln!(f, " {:?}: {:?}", key, val); } res } diff --git a/src/httpresponse.rs b/src/httpresponse.rs index 5edb6de5..90243e4d 100644 --- a/src/httpresponse.rs +++ b/src/httpresponse.rs @@ -241,13 +241,13 @@ impl HttpResponse { impl fmt::Debug for HttpResponse { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - let res = write!(f, "\nHttpResponse {:?} {}{}\n", + let res = writeln!(f, "\nHttpResponse {:?} {}{}", self.get_ref().version, self.get_ref().status, self.get_ref().reason.unwrap_or("")); - let _ = write!(f, " encoding: {:?}\n", self.get_ref().encoding); - let _ = write!(f, " headers:\n"); + let _ = writeln!(f, " encoding: {:?}", self.get_ref().encoding); + let _ = writeln!(f, " headers:"); for (key, val) in self.get_ref().headers.iter() { - let _ = write!(f, " {:?}: {:?}\n", key, val); + let _ = writeln!(f, " {:?}: {:?}", key, val); } res } diff --git a/src/multipart.rs b/src/multipart.rs index 4ac7b2a1..a8d0c6e7 100644 --- a/src/multipart.rs +++ b/src/multipart.rs @@ -396,11 +396,11 @@ impl Stream for Field where S: Stream { impl fmt::Debug for Field { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - let res = write!(f, "\nMultipartField: {}\n", self.ct); - let _ = write!(f, " boundary: {}\n", self.inner.borrow().boundary); - let _ = write!(f, " headers:\n"); + let res = writeln!(f, "\nMultipartField: {}", self.ct); + let _ = writeln!(f, " boundary: {}", self.inner.borrow().boundary); + let _ = writeln!(f, " headers:"); for (key, val) in self.headers.iter() { - let _ = write!(f, " {:?}: {:?}\n", key, val); + let _ = writeln!(f, " {:?}: {:?}", key, val); } res } diff --git a/src/server/encoding.rs b/src/server/encoding.rs index fc624d55..fd2ca432 100644 --- a/src/server/encoding.rs +++ b/src/server/encoding.rs @@ -718,7 +718,7 @@ impl TransferEncoding { self.buffer.extend_from_slice(b"0\r\n\r\n"); } else { let mut buf = BytesMut::new(); - write!(&mut buf, "{:X}\r\n", msg.len()) + writeln!(&mut buf, "{:X}\r", msg.len()) .map_err(|e| io::Error::new(io::ErrorKind::Other, e))?; self.buffer.reserve(buf.len() + msg.len() + 2); self.buffer.extend(buf.into());