Skip to content

Commit 0d274df

Browse files
committed
Use more constants for headers
1 parent 0a4f6d7 commit 0d274df

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/util.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ impl UriExt for Uri {
335335
}
336336

337337
pub(crate) trait HeaderMapExt {
338-
fn get_str(&self, k: &str) -> Option<&str>;
338+
fn get_str(&self, k: HeaderName) -> Option<&str>;
339339
fn is_chunked(&self) -> bool;
340340
fn content_length(&self) -> Option<u64>;
341341
fn has_accept_encoding(&self) -> bool;
@@ -349,39 +349,39 @@ pub(crate) trait HeaderMapExt {
349349
}
350350

351351
impl HeaderMapExt for HeaderMap {
352-
fn get_str(&self, k: &str) -> Option<&str> {
352+
fn get_str(&self, k: HeaderName) -> Option<&str> {
353353
self.get(k).and_then(|v| v.to_str().ok())
354354
}
355355

356356
fn is_chunked(&self) -> bool {
357-
self.get_str("transfer-encoding")
357+
self.get_str(TRANSFER_ENCODING)
358358
.map(|v| v.contains("chunked"))
359359
.unwrap_or(false)
360360
}
361361

362362
fn content_length(&self) -> Option<u64> {
363-
let h = self.get_str("content-length")?;
363+
let h = self.get_str(CONTENT_LENGTH)?;
364364
let len: u64 = h.parse().ok()?;
365365
Some(len)
366366
}
367367

368368
fn has_accept_encoding(&self) -> bool {
369-
self.contains_key("accept-encoding")
369+
self.contains_key(ACCEPT_ENCODING)
370370
}
371371

372372
fn has_user_agent(&self) -> bool {
373-
self.contains_key("user-agent")
373+
self.contains_key(USER_AGENT)
374374
}
375375

376376
fn has_accept(&self) -> bool {
377-
self.contains_key("accept")
377+
self.contains_key(ACCEPT)
378378
}
379379

380380
fn has_content_type(&self) -> bool {
381-
self.contains_key("content-type")
381+
self.contains_key(CONTENT_TYPE)
382382
}
383383

384384
fn has_location(&self) -> bool {
385-
self.contains_key("location")
385+
self.contains_key(LOCATION)
386386
}
387387
}

0 commit comments

Comments
 (0)