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:
25
src/header/common/server.rs
Normal file
25
src/header/common/server.rs
Normal file
@@ -0,0 +1,25 @@
|
||||
use header::Header;
|
||||
use std::fmt::{mod, Show};
|
||||
use super::from_one_raw_str;
|
||||
|
||||
/// The `Server` header field.
|
||||
///
|
||||
/// They can contain any value, so it just wraps a `String`.
|
||||
#[deriving(Clone, PartialEq, Show)]
|
||||
pub struct Server(pub String);
|
||||
|
||||
impl Header for Server {
|
||||
fn header_name(_: Option<Server>) -> &'static str {
|
||||
"server"
|
||||
}
|
||||
|
||||
fn parse_header(raw: &[Vec<u8>]) -> Option<Server> {
|
||||
from_one_raw_str(raw).map(|s| Server(s))
|
||||
}
|
||||
|
||||
fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
let Server(ref value) = *self;
|
||||
value.fmt(fmt)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user