@@ -73,25 +73,37 @@ impl<'a> std::convert::TryFrom<&'a str> for HeaderName {
73
73
74
74
impl PartialEq < str > for HeaderName {
75
75
fn eq ( & self , other : & str ) -> bool {
76
- self . 0 == other
76
+ match HeaderName :: from_str ( other) {
77
+ Err ( _) => return false ,
78
+ Ok ( other) => self == & other,
79
+ }
77
80
}
78
81
}
79
82
80
83
impl < ' a > PartialEq < & ' a str > for HeaderName {
81
84
fn eq ( & self , other : & & ' a str ) -> bool {
82
- & self . 0 == other
85
+ match HeaderName :: from_str ( other) {
86
+ Err ( _) => return false ,
87
+ Ok ( other) => self == & other,
88
+ }
83
89
}
84
90
}
85
91
86
92
impl PartialEq < String > for HeaderName {
87
93
fn eq ( & self , other : & String ) -> bool {
88
- & self . 0 == other
94
+ match HeaderName :: from_str ( & other) {
95
+ Err ( _) => return false ,
96
+ Ok ( other) => self == & other,
97
+ }
89
98
}
90
99
}
91
100
92
101
impl < ' a > PartialEq < & String > for HeaderName {
93
102
fn eq ( & self , other : & & String ) -> bool {
94
- & & self . 0 == other
103
+ match HeaderName :: from_str ( other) {
104
+ Err ( _) => return false ,
105
+ Ok ( other) => self == & other,
106
+ }
95
107
}
96
108
}
97
109
@@ -120,5 +132,8 @@ mod tests {
120
132
assert_eq ! ( & static_header, "hello" ) ;
121
133
assert_eq ! ( static_header, String :: from( "hello" ) ) ;
122
134
assert_eq ! ( static_header, & String :: from( "hello" ) ) ;
135
+
136
+ // Must validate regardless of casing.
137
+ assert_eq ! ( static_header, & String :: from( "Hello" ) ) ;
123
138
}
124
139
}
0 commit comments