Split common headers into a submodule and into their own files

This is a more extensible place to put them and doesn't clutter up
header/mod.rs as much as the old scheme did.

Fixes #8
This commit is contained in:
Jonathan Reem
2014-09-08 16:12:47 -07:00
parent fd6b014e7e
commit f2c09c5743
17 changed files with 727 additions and 637 deletions

View File

@@ -0,0 +1,25 @@
use header::Header;
use std::fmt::{mod, Show};
use super::from_one_raw_str;
/// The `User-Agent` header field.
///
/// They can contain any value, so it just wraps a `String`.
#[deriving(Clone, PartialEq, Show)]
pub struct UserAgent(pub String);
impl Header for UserAgent {
fn header_name(_: Option<UserAgent>) -> &'static str {
"user-agent"
}
fn parse_header(raw: &[Vec<u8>]) -> Option<UserAgent> {
from_one_raw_str(raw).map(|s| UserAgent(s))
}
fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
let UserAgent(ref value) = *self;
value.fmt(fmt)
}
}