File tree 3 files changed +21
-5
lines changed
3 files changed +21
-5
lines changed Original file line number Diff line number Diff line change 1
1
use super :: HeaderValue ;
2
2
use super :: name:: { HeaderName , HdrName , InvalidHeaderName } ;
3
- use convert:: HttpTryFrom ;
3
+ use convert:: { HttpTryFrom , HttpTryInto } ;
4
4
use Error ;
5
5
use sealed:: Sealed ;
6
6
@@ -1747,16 +1747,16 @@ impl<T> Sealed for HeaderMap<T> {}
1747
1747
impl < COLLECTION , K , V > HttpTryFrom < COLLECTION > for HeaderMap < HeaderValue >
1748
1748
where
1749
1749
COLLECTION : IntoIterator < Item =( K , V ) > ,
1750
- K : AsRef < str > ,
1751
- V : AsRef < str >
1750
+ HeaderName : HttpTryFrom < K > ,
1751
+ HeaderValue : HttpTryFrom < V >
1752
1752
{
1753
1753
type Error = Error ;
1754
1754
1755
1755
fn try_from ( c : COLLECTION ) -> Result < Self , Self :: Error > {
1756
1756
c. into_iter ( )
1757
1757
. map ( |( k, v) | -> :: Result < ( HeaderName , HeaderValue ) > {
1758
- let name = k. as_ref ( ) . parse ( ) ?;
1759
- let value = v. as_ref ( ) . parse ( ) ?;
1758
+ let name : HeaderName = k. http_try_into ( ) ?;
1759
+ let value : HeaderValue = v. http_try_into ( ) ?;
1760
1760
Ok ( ( name, value) )
1761
1761
} )
1762
1762
. collect ( )
Original file line number Diff line number Diff line change @@ -1772,6 +1772,14 @@ impl<'a> HttpTryFrom<&'a str> for HeaderName {
1772
1772
}
1773
1773
}
1774
1774
1775
+ impl < ' a > HttpTryFrom < & ' a String > for HeaderName {
1776
+ type Error = InvalidHeaderName ;
1777
+ #[ inline]
1778
+ fn try_from ( s : & ' a String ) -> Result < Self , Self :: Error > {
1779
+ Self :: from_bytes ( s. as_bytes ( ) )
1780
+ }
1781
+ }
1782
+
1775
1783
impl < ' a > HttpTryFrom < & ' a [ u8 ] > for HeaderName {
1776
1784
type Error = InvalidHeaderName ;
1777
1785
#[ inline]
Original file line number Diff line number Diff line change @@ -521,6 +521,14 @@ impl<'a> HttpTryFrom<&'a str> for HeaderValue {
521
521
}
522
522
}
523
523
524
+ impl < ' a > HttpTryFrom < & ' a String > for HeaderValue {
525
+ type Error = InvalidHeaderValue ;
526
+ #[ inline]
527
+ fn try_from ( s : & ' a String ) -> Result < Self , Self :: Error > {
528
+ Self :: from_bytes ( s. as_bytes ( ) )
529
+ }
530
+ }
531
+
524
532
impl < ' a > HttpTryFrom < & ' a [ u8 ] > for HeaderValue {
525
533
type Error = InvalidHeaderValue ;
526
534
You can’t perform that action at this time.
0 commit comments