File tree 2 files changed +29
-0
lines changed
2 files changed +29
-0
lines changed Original file line number Diff line number Diff line change
1
+ use header:: { self , QualityItem } ;
2
+
3
+ pub type Charset = String ;
4
+
5
+ /// The `Accept-Charset` header
6
+ ///
7
+ /// The `Accept-Charset` header can be used by clients to indicate what
8
+ /// response charsets they accept.
9
+ #[ derive( Clone , PartialEq , Debug ) ]
10
+ pub struct AcceptCharset ( pub Vec < QualityItem < Charset > > ) ;
11
+
12
+ impl_list_header ! ( AcceptCharset ,
13
+ "Accept-Charset" ,
14
+ Vec <QualityItem <Charset >>) ;
15
+
16
+
17
+ #[ test]
18
+ fn test_parse_header ( ) {
19
+ let a: AcceptCharset = header:: Header :: parse_header (
20
+ [ b"iso-8859-5, unicode-1-1;q=0.8" . to_vec ( ) ] . as_slice ( ) ) . unwrap ( ) ;
21
+ let b = AcceptCharset ( vec ! [
22
+ QualityItem { item: "iso-8859-5" . to_string( ) , quality: 1.0 } ,
23
+ QualityItem { item: "unicode-1-1" . to_string( ) , quality: 0.8 } ,
24
+ ] ) ;
25
+ assert_eq ! ( format!( "{}" , a) , format!( "{}" , b) ) ;
26
+ assert_eq ! ( a, b) ;
27
+ }
Original file line number Diff line number Diff line change 8
8
9
9
pub use self :: access_control:: * ;
10
10
pub use self :: accept:: Accept ;
11
+ pub use self :: accept_charset:: AcceptCharset ;
11
12
pub use self :: accept_encoding:: AcceptEncoding ;
12
13
pub use self :: accept_language:: AcceptLanguage ;
13
14
pub use self :: allow:: Allow ;
@@ -147,6 +148,7 @@ macro_rules! impl_header(
147
148
148
149
mod access_control;
149
150
mod accept;
151
+ mod accept_charset;
150
152
mod accept_encoding;
151
153
mod accept_language;
152
154
mod allow;
You can’t perform that action at this time.
0 commit comments