forked from hyperium/hyper
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(headers): Use macros for headers where possible
- Loading branch information
Showing
11 changed files
with
72 additions
and
204 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,11 @@ | ||
use std::fmt; | ||
|
||
use header::{Header, HeaderFormat}; | ||
use header::parsing::from_one_raw_str; | ||
|
||
/// The `Content-Length` header. | ||
/// | ||
/// Simply a wrapper around a `usize`. | ||
/// Simply a wrapper around a `u64`. | ||
#[derive(Copy, Clone, PartialEq, Debug)] | ||
pub struct ContentLength(pub u64); | ||
|
||
deref!(ContentLength => u64); | ||
|
||
impl Header for ContentLength { | ||
fn header_name() -> &'static str { | ||
"Content-Length" | ||
} | ||
|
||
fn parse_header(raw: &[Vec<u8>]) -> Option<ContentLength> { | ||
from_one_raw_str(raw).map(|u| ContentLength(u)) | ||
} | ||
} | ||
|
||
impl HeaderFormat for ContentLength { | ||
fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { | ||
fmt::Display::fmt(&self.0, fmt) | ||
} | ||
} | ||
impl_header!(ContentLength, | ||
"Content-Length", | ||
u64); | ||
|
||
bench_header!(bench, ContentLength, { vec![b"42349984".to_vec()] }); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
use header; | ||
|
||
/// The `Server` header field. | ||
/// | ||
/// They can contain any value, so it just wraps a `String`. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.