Skip to content

Commit 53073ae

Browse files
committed
Forgot and fixed conversion from HeaderValue to boolean
1 parent c557349 commit 53073ae

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

my-http-server-core/src/http_headers/header_value.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ use crate::{
1010
};
1111

1212
pub struct HeaderValue<'s> {
13-
name: &'static str,
14-
value: &'s [u8],
13+
pub name: &'static str,
14+
pub value: &'s [u8],
1515
}
1616

1717
impl<'s> HeaderValue<'s> {
@@ -97,6 +97,14 @@ impl TryInto<u8> for HeaderValue<'_> {
9797
}
9898
}
9999

100+
impl TryInto<bool> for HeaderValue<'_> {
101+
type Error = HttpFailResult;
102+
fn try_into(self) -> Result<bool, Self::Error> {
103+
let value = self.as_str()?;
104+
crate::convert_from_str::to_bool(self.name, value, SRC_HEADER)
105+
}
106+
}
107+
100108
impl TryInto<i8> for HeaderValue<'_> {
101109
type Error = HttpFailResult;
102110
fn try_into(self) -> Result<i8, Self::Error> {

0 commit comments

Comments
 (0)