Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions src/header/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ use std::hash;
use std::intrinsics::TypeId;
use std::mem::{transmute, transmute_copy};
use std::raw::TraitObject;
use std::str::{from_utf8, SendStr, Slice, Owned};
use std::string::raw;
use std::str::{SendStr, Slice, Owned};
use std::collections::hashmap::{HashMap, Entries, Occupied, Vacant};
use std::sync::RWLock;

Expand Down Expand Up @@ -95,12 +94,6 @@ impl Headers {
loop {
match try!(read_header(rdr)) {
Some((name, value)) => {
// read_header already checks that name is a token, which
// means its safe utf8
let name = unsafe {
raw::from_utf8(name)
};

let name = CaseInsensitive(Owned(name));
let item = match headers.data.entry(name) {
Vacant(entry) => entry.set(RWLock::new(Raw(vec![]))),
Expand Down
10 changes: 5 additions & 5 deletions src/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -520,9 +520,9 @@ pub fn read_http_version<R: Reader>(stream: &mut R) -> HttpResult<HttpVersion> {

/// The raw bytes when parsing a header line.
///
/// 2 vectors of u8s, divided by COLON (`:`). The first vector is guaranteed
/// A String and Vec<u8>, divided by COLON (`:`). The String is guaranteed
/// to be all `token`s. See `is_token_char` source for all valid characters.
pub type RawHeaderLine = (Vec<u8>, Vec<u8>);
pub type RawHeaderLine = (String, Vec<u8>);

/// Read a RawHeaderLine from a Reader.
///
Expand All @@ -545,7 +545,7 @@ pub type RawHeaderLine = (Vec<u8>, Vec<u8>);
/// > ; see Section 3.2.4
/// > ```
pub fn read_header<R: Reader>(stream: &mut R) -> HttpResult<Option<RawHeaderLine>> {
let mut name = vec![];
let mut name = String::new();
let mut value = vec![];

loop {
Expand All @@ -557,7 +557,7 @@ pub fn read_header<R: Reader>(stream: &mut R) -> HttpResult<Option<RawHeaderLine
}
},
b':' => break,
b if is_token(b) => name.push(b),
b if is_token(b) => name.push(b as char),
_nontoken => return Err(HttpHeaderError)
};
}
Expand Down Expand Up @@ -745,7 +745,7 @@ mod tests {
assert_eq!(read_header(&mut mem(s)), result);
}

read("Host: rust-lang.org\r\n", Ok(Some(("Host".as_bytes().to_vec(),
read("Host: rust-lang.org\r\n", Ok(Some(("Host".to_string(),
"rust-lang.org".as_bytes().to_vec()))));
}

Expand Down