File tree Expand file tree Collapse file tree 2 files changed +10
-9
lines changed Expand file tree Collapse file tree 2 files changed +10
-9
lines changed Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ use std::slice;
2929/// accept.push(EncodingProposal::new(Encoding::Identity, None)?);
3030///
3131/// let mut res = Response::new(200);
32- /// let encoding = accept.negotiate(&[Encoding::Gzip , Encoding::Brotli ])?;
32+ /// let encoding = accept.negotiate(&[Encoding::Brotli , Encoding::Gzip ])?;
3333/// encoding.apply(&mut res);
3434///
3535/// assert_eq!(res["Content-Encoding"], "br");
@@ -135,7 +135,7 @@ impl AcceptEncoding {
135135 Err ( err)
136136 }
137137
138- /// Insert a `HeaderName` + `HeaderValue` pair into a `Headers` instance .
138+ /// Sets the `Accept-Encoding` header .
139139 pub fn apply ( & self , mut headers : impl AsMut < Headers > ) {
140140 headers. as_mut ( ) . insert ( ACCEPT_ENCODING , self . value ( ) ) ;
141141 }
Original file line number Diff line number Diff line change @@ -50,20 +50,16 @@ impl ContentEncoding {
5050 let mut inner = None ;
5151
5252 for value in headers {
53- for part in value. as_str ( ) . trim ( ) . split ( ',' ) {
54- // Try and parse a directive from a str. If the directive is
55- // unkown we skip it.
56- if let Some ( entry) = Encoding :: from_str ( part) {
57- inner = Some ( entry) ;
58- }
53+ if let Some ( entry) = Encoding :: from_str ( value. as_str ( ) ) {
54+ inner = Some ( entry) ;
5955 }
6056 }
6157
6258 let inner = inner. expect ( "Headers instance with no entries found" ) ;
6359 Ok ( Some ( Self { inner } ) )
6460 }
6561
66- /// Sets the `Server-Timing ` header.
62+ /// Sets the `Content-Encoding ` header.
6763 pub fn apply ( & self , mut headers : impl AsMut < Headers > ) {
6864 headers. as_mut ( ) . insert ( CONTENT_ENCODING , self . value ( ) ) ;
6965 }
@@ -77,6 +73,11 @@ impl ContentEncoding {
7773 pub fn value ( & self ) -> HeaderValue {
7874 self . inner . into ( )
7975 }
76+
77+ /// Access the encoding kind.
78+ pub fn encoding ( & self ) -> Encoding {
79+ self . inner
80+ }
8081}
8182
8283impl ToHeaderValues for ContentEncoding {
You can’t perform that action at this time.
0 commit comments