Skip to content

Commit 9a0e44d

Browse files
committed
fix to avoid empty CONTENT_TYPE
1 parent 6b4017c commit 9a0e44d

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

ohkami/src/typed/status.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,15 @@ 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 self.body.into_body() {
47-
Ok(body) => body,
48-
Err(e) => {
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)) => {
4951
crate::ERROR!("<{} as IntoBody>::into_body() failed: {e}", std::any::type_name::<B>());
5052
return Response::InternalServerError();
5153
}
54+
(_, Ok(body)) => body,
5255
};
5356

5457
let mut headers = self.headers;

0 commit comments

Comments
 (0)