diff --git a/ntex-router/src/path.rs b/ntex-router/src/path.rs index 56ea1dcd..99179482 100644 --- a/ntex-router/src/path.rs +++ b/ntex-router/src/path.rs @@ -122,7 +122,7 @@ impl Path { for item in self.segments.iter() { if key == item.0 { return match item.1 { - PathItem::Static(ref s) => Some(&s), + PathItem::Static(s) => Some(s), PathItem::Segment(ref s) => Some(s), PathItem::IdxSegment(s, e) => { Some(&self.path.path()[(s as usize)..(e as usize)]) @@ -192,7 +192,7 @@ impl<'a, T: ResourcePath> Iterator for PathIter<'a, T> { } }; self.idx += 1; - return Some((&self.params.segments[idx].0, res)); + return Some((self.params.segments[idx].0, res)); } None } @@ -212,8 +212,8 @@ impl Index for Path { fn index(&self, idx: usize) -> &str { match self.segments[idx].1 { - PathItem::Static(ref s) => &s, - PathItem::Segment(ref s) => &s, + PathItem::Static(s) => s, + PathItem::Segment(ref s) => s, PathItem::IdxSegment(s, e) => &self.path.path()[(s as usize)..(e as usize)], } } diff --git a/ntex-router/src/resource.rs b/ntex-router/src/resource.rs index 414ef0dd..af1898dc 100644 --- a/ntex-router/src/resource.rs +++ b/ntex-router/src/resource.rs @@ -260,7 +260,7 @@ impl ResourceDef { } let p = pattern.split_at(start_idx); pattern = p.1; - re.push_str(&escape(&p.0)); + re.push_str(&escape(p.0)); elems.push(PathElement::Str(p.0.to_string())); // find closing } diff --git a/ntex-router/src/tree.rs b/ntex-router/src/tree.rs index ce03df0b..41b35b73 100644 --- a/ntex-router/src/tree.rs +++ b/ntex-router/src/tree.rs @@ -447,7 +447,7 @@ impl Tree { if let Some(captures) = pattern.captures(seg) { let mut is_match = true; for name in names.iter() { - if let Some(m) = captures.name(&name) { + if let Some(m) = captures.name(name) { let item = if quoted { PathItem::Segment(m.as_str().to_string()) } else { diff --git a/ntex/src/connect/message.rs b/ntex/src/connect/message.rs index f0059f95..409eb5e0 100644 --- a/ntex/src/connect/message.rs +++ b/ntex/src/connect/message.rs @@ -21,7 +21,7 @@ pub trait Address: Unpin + 'static { impl Address for String { fn host(&self) -> &str { - &self + self } fn port(&self) -> Option { diff --git a/ntex/src/framed/dispatcher.rs b/ntex/src/framed/dispatcher.rs index f27cbdad..35e2489c 100644 --- a/ntex/src/framed/dispatcher.rs +++ b/ntex/src/framed/dispatcher.rs @@ -225,7 +225,7 @@ where loop { match slf.st.get() { DispatcherState::Processing => { - let result = match slf.poll_service(&this.service, cx, read) { + let result = match slf.poll_service(this.service, cx, read) { Poll::Pending => return Poll::Pending, Poll::Ready(result) => result, }; @@ -284,7 +284,7 @@ where } // handle write back-pressure DispatcherState::Backpressure => { - let result = match slf.poll_service(&this.service, cx, read) { + let result = match slf.poll_service(this.service, cx, read) { Poll::Ready(result) => result, Poll::Pending => return Poll::Pending, }; diff --git a/ntex/src/http/h1/decoder.rs b/ntex/src/http/h1/decoder.rs index 188403f7..f61f34e5 100644 --- a/ntex/src/http/h1/decoder.rs +++ b/ntex/src/http/h1/decoder.rs @@ -125,13 +125,11 @@ pub(super) trait MessageType: Sized { && content_length.is_none() { chunked = true + } else if s.eq_ignore_ascii_case("identity") { + // allow silently since multiple TE headers are already checked } else { - if s.eq_ignore_ascii_case("identity") { - // allow silently since multiple TE headers are already checked - } else { - log::debug!("illegal Transfer-Encoding: {:?}", s); - return Err(ParseError::Header); - } + log::debug!("illegal Transfer-Encoding: {:?}", s); + return Err(ParseError::Header); } } else { return Err(ParseError::Header); diff --git a/ntex/src/http/h1/encoder.rs b/ntex/src/http/h1/encoder.rs index 9120eab2..c9249327 100644 --- a/ntex/src/http/h1/encoder.rs +++ b/ntex/src/http/h1/encoder.rs @@ -80,6 +80,7 @@ pub(super) trait MessageType: Sized { BodySize::Sized(len) => write_content_length(len, dst), BodySize::Stream => { if chunked { + skip_len = true; dst.extend_from_slice(b"\r\ntransfer-encoding: chunked\r\n") } else { skip_len = false; diff --git a/ntex/src/http/message.rs b/ntex/src/http/message.rs index b0b7d36c..a441a8ee 100644 --- a/ntex/src/http/message.rs +++ b/ntex/src/http/message.rs @@ -185,7 +185,7 @@ impl RequestHeadType { impl AsRef for RequestHeadType { fn as_ref(&self) -> &RequestHead { match self { - RequestHeadType::Owned(head) => &head, + RequestHeadType::Owned(head) => head, RequestHeadType::Rc(head, _) => head.as_ref(), } } @@ -369,7 +369,7 @@ impl std::ops::Deref for Message { type Target = T; fn deref(&self) -> &Self::Target { - &self.head.as_ref() + self.head.as_ref() } } diff --git a/ntex/src/server/config.rs b/ntex/src/server/config.rs index d70b9078..34820887 100644 --- a/ntex/src/server/config.rs +++ b/ntex/src/server/config.rs @@ -244,7 +244,7 @@ impl ServiceRuntime { fn validate(&self) { let inner = self.0.as_ref().borrow(); for (name, token) in &inner.names { - if !inner.services.contains_key(&token) { + if !inner.services.contains_key(token) { error!("Service {:?} is not configured", name); } } diff --git a/ntex/src/web/request.rs b/ntex/src/web/request.rs index 4b0f159f..bdf985e7 100644 --- a/ntex/src/web/request.rs +++ b/ntex/src/web/request.rs @@ -90,7 +90,7 @@ impl WebRequest { /// This method returns reference to the request head #[inline] pub fn head(&self) -> &RequestHead { - &self.req.head() + self.req.head() } /// This method returns reference to the request head diff --git a/ntex/tests/http_server.rs b/ntex/tests/http_server.rs index 1b2360db..acb89ec8 100644 --- a/ntex/tests/http_server.rs +++ b/ntex/tests/http_server.rs @@ -528,6 +528,7 @@ async fn test_h1_body_length() { #[ntex::test] async fn test_h1_body_chunked_explicit() { + env_logger::init(); let mut srv = test_server(|| { HttpService::build() .h1(|_| {