Skip to content

Commit 89e76e5

Browse files
committed
refactor(http1): simplify match of Token parse error
1 parent 2968dbc commit 89e76e5

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

src/proto/h1/role.rs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -188,20 +188,18 @@ impl Http1Transaction for Server {
188188
headers_len = req.headers.len();
189189
}
190190
Ok(httparse::Status::Partial) => return Ok(None),
191-
Err(err) => {
192-
return Err(match err {
193-
// if invalid Token, try to determine if for method or path
194-
httparse::Error::Token => {
195-
if req.method.is_none() {
196-
Parse::Method
197-
} else {
198-
debug_assert!(req.path.is_none());
199-
Parse::Uri
200-
}
191+
// if invalid Token, try to determine if for method or path
192+
Err(httparse::Error::Token) => {
193+
return Err({
194+
if req.method.is_none() {
195+
Parse::Method
196+
} else {
197+
debug_assert!(req.path.is_none());
198+
Parse::Uri
201199
}
202-
other => other.into(),
203-
});
200+
})
204201
}
202+
Err(err) => return Err(err.into()),
205203
}
206204
};
207205

0 commit comments

Comments
 (0)