move rendering of headers to the Headers object

This commit is contained in:
Sean McArthur
2014-10-08 10:23:34 -07:00
parent f2d2ed93d3
commit 2f755a5694
5 changed files with 44 additions and 17 deletions

View File

@@ -1,5 +1,6 @@
//! Pieces pertaining to the HTTP message protocol.
use std::cmp::min;
use std::fmt;
use std::io::{mod, Reader, IoResult};
use std::u16;
@@ -211,6 +212,23 @@ pub const LF: u8 = b'\n';
pub const STAR: u8 = b'*';
pub const LINE_ENDING: &'static [u8] = &[CR, LF];
/// A `Show`able struct to easily write line endings to a formatter.
pub struct LineEnding;
impl fmt::Show for LineEnding {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
fmt.write(LINE_ENDING)
}
}
impl Slice<u8> for LineEnding {
fn as_slice(&self) -> &[u8] {
LINE_ENDING
}
}
/// Determines if byte is a token char.
///
/// > ```notrust