This commit is contained in:
Nikolay Kim 2021-08-14 19:52:36 +06:00
parent 73c172400c
commit e57b712f7b
11 changed files with 19 additions and 19 deletions

View file

@ -122,7 +122,7 @@ impl<T: ResourcePath> Path<T> {
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<T: ResourcePath> Index<usize> for Path<T> {
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)],
}
}

View file

@ -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 }

View file

@ -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 {

View file

@ -21,7 +21,7 @@ pub trait Address: Unpin + 'static {
impl Address for String {
fn host(&self) -> &str {
&self
self
}
fn port(&self) -> Option<u16> {

View file

@ -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,
};

View file

@ -125,14 +125,12 @@ pub(super) trait MessageType: Sized {
&& content_length.is_none()
{
chunked = true
} else {
if s.eq_ignore_ascii_case("identity") {
} 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);
}
}
} else {
return Err(ParseError::Header);
}

View file

@ -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;

View file

@ -185,7 +185,7 @@ impl RequestHeadType {
impl AsRef<RequestHead> 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<T: Head> std::ops::Deref for Message<T> {
type Target = T;
fn deref(&self) -> &Self::Target {
&self.head.as_ref()
self.head.as_ref()
}
}

View file

@ -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);
}
}

View file

@ -90,7 +90,7 @@ impl<Err> WebRequest<Err> {
/// 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

View file

@ -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(|_| {