Skip to content

Commit f1ee571

Browse files
committed
fix to check B::CONTENT_TYPE.is_empty() before evaluating into_body()
1 parent 9a0e44d commit f1ee571

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

ohkami/src/typed/status.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,16 @@ macro_rules! generate_statuses_as_types_containing_value {
4343
impl<B: IntoBody> IntoResponse for $status<B> {
4444
#[inline]
4545
fn into_response(self) -> Response {
46-
let body = match (const {B::CONTENT_TYPE}, self.body.into_body()) {
47-
("", _) => {// will be removed by optimization if it's not
48-
return Response::OK();
49-
}
50-
(_, Err(e)) => {
46+
if const {B::CONTENT_TYPE.is_empty()} {// will be removed by optimization if it's not
47+
return Response::OK();
48+
}
49+
50+
let body = match self.body.into_body() {
51+
Ok(body) => body,
52+
Err(e) => {
5153
crate::ERROR!("<{} as IntoBody>::into_body() failed: {e}", std::any::type_name::<B>());
5254
return Response::InternalServerError();
5355
}
54-
(_, Ok(body)) => body,
5556
};
5657

5758
let mut headers = self.headers;

0 commit comments

Comments
 (0)