Skip to content

Commit 5ea814f

Browse files
committed
Apply feedback from review
1 parent 1b5778e commit 5ea814f

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

src/content/accept_encoding.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff 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
}

src/content/content_encoding.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff 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

8283
impl ToHeaderValues for ContentEncoding {

0 commit comments

Comments
 (0)