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:
		
							
								
								
									
										29
									
								
								src/header/common/host.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								src/header/common/host.rs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,29 @@ | ||||
| use header::Header; | ||||
| use std::fmt::{mod, Show}; | ||||
| use super::from_one_raw_str; | ||||
|  | ||||
| /// The `Host` header. | ||||
| /// | ||||
| /// HTTP/1.1 requires that all requests include a `Host` header, and so hyper | ||||
| /// client requests add one automatically. | ||||
| /// | ||||
| /// Currently is just a String, but it should probably become a better type, | ||||
| /// like url::Host or something. | ||||
| #[deriving(Clone, PartialEq, Show)] | ||||
| pub struct Host(pub String); | ||||
|  | ||||
| impl Header for Host { | ||||
|     fn header_name(_: Option<Host>) -> &'static str { | ||||
|         "host" | ||||
|     } | ||||
|  | ||||
|     fn parse_header(raw: &[Vec<u8>]) -> Option<Host> { | ||||
|         from_one_raw_str(raw).map(|s| Host(s)) | ||||
|     } | ||||
|  | ||||
|     fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { | ||||
|         let Host(ref value) = *self; | ||||
|         value.fmt(fmt) | ||||
|     } | ||||
| } | ||||
|  | ||||
		Reference in New Issue
	
	Block a user