Merge pull request #63 from reem/de-deprecate-parse-delete
Remove deprecated items and parse DELETE
This commit is contained in:
@@ -12,7 +12,7 @@ use std::mem::{transmute, transmute_copy};
|
|||||||
use std::raw::TraitObject;
|
use std::raw::TraitObject;
|
||||||
use std::str::{from_utf8, SendStr, Slice, Owned};
|
use std::str::{from_utf8, SendStr, Slice, Owned};
|
||||||
use std::string::raw;
|
use std::string::raw;
|
||||||
use std::collections::hashmap::{HashMap, Entries};
|
use std::collections::hashmap::{HashMap, Entries, Occupied, Vacant};
|
||||||
|
|
||||||
use uany::UncheckedAnyDowncast;
|
use uany::UncheckedAnyDowncast;
|
||||||
use typeable::Typeable;
|
use typeable::Typeable;
|
||||||
@@ -91,8 +91,12 @@ impl Headers {
|
|||||||
let name = unsafe {
|
let name = unsafe {
|
||||||
raw::from_utf8(name)
|
raw::from_utf8(name)
|
||||||
};
|
};
|
||||||
let name = CaseInsensitive(Owned(name));
|
|
||||||
let item = headers.data.find_or_insert(name, Raw(vec![]));
|
let item = match headers.data.entry(CaseInsensitive(Owned(name))) {
|
||||||
|
Vacant(entry) => entry.set(Raw(vec![])),
|
||||||
|
Occupied(entry) => entry.into_mut()
|
||||||
|
};
|
||||||
|
|
||||||
match *item {
|
match *item {
|
||||||
Raw(ref mut raw) => raw.push(value),
|
Raw(ref mut raw) => raw.push(value),
|
||||||
// Unreachable
|
// Unreachable
|
||||||
|
|||||||
17
src/http.rs
17
src/http.rs
@@ -359,9 +359,10 @@ pub fn read_method<R: Reader>(stream: &mut R) -> HttpResult<method::Method> {
|
|||||||
(MsStart, b'O') => state = MsO,
|
(MsStart, b'O') => state = MsO,
|
||||||
(MsStart, b'T') => state = MsT,
|
(MsStart, b'T') => state = MsT,
|
||||||
(MsStart, b'C') => state = MsC,
|
(MsStart, b'C') => state = MsC,
|
||||||
|
(MsStart, b'D') => state = MsD,
|
||||||
(MsStart, b@b'A'..b'Z') => {
|
(MsStart, b@b'A'..b'Z') => {
|
||||||
state = MsExt;
|
state = MsExt;
|
||||||
s.push_char(b as char)
|
s.push(b as char)
|
||||||
},
|
},
|
||||||
|
|
||||||
(MsG, b'E') => state = MsGE,
|
(MsG, b'E') => state = MsGE,
|
||||||
@@ -402,11 +403,17 @@ pub fn read_method<R: Reader>(stream: &mut R) -> HttpResult<method::Method> {
|
|||||||
(MsCONNE, b'C') => state = MsCONNEC,
|
(MsCONNE, b'C') => state = MsCONNEC,
|
||||||
(MsCONNEC, b'T') => state = MsCONNECT,
|
(MsCONNEC, b'T') => state = MsCONNECT,
|
||||||
|
|
||||||
(MsExt, b@b'A'..b'Z') => s.push_char(b as char),
|
(MsD, b'E') => state = MsDE,
|
||||||
|
(MsDE, b'L') => state = MsDEL,
|
||||||
|
(MsDEL, b'E') => state = MsDELE,
|
||||||
|
(MsDELE, b'T') => state = MsDELET,
|
||||||
|
(MsDELET, b'E') => state = MsDELETE,
|
||||||
|
|
||||||
|
(MsExt, b@b'A'..b'Z') => s.push(b as char),
|
||||||
|
|
||||||
(_, b@b'A'..b'Z') => {
|
(_, b@b'A'..b'Z') => {
|
||||||
s = state.as_slice().to_string();
|
s = state.as_slice().to_string();
|
||||||
s.push_char(b as char);
|
s.push(b as char);
|
||||||
},
|
},
|
||||||
|
|
||||||
(MsGET, SP) => return Ok(method::Get),
|
(MsGET, SP) => return Ok(method::Get),
|
||||||
@@ -437,7 +444,7 @@ pub fn read_uri<R: Reader>(stream: &mut R) -> HttpResult<uri::RequestUri> {
|
|||||||
try!(expect(stream.read_byte(), SP));
|
try!(expect(stream.read_byte(), SP));
|
||||||
return Ok(uri::Star)
|
return Ok(uri::Star)
|
||||||
} else {
|
} else {
|
||||||
s.push_char(b as char);
|
s.push(b as char);
|
||||||
loop {
|
loop {
|
||||||
match try_io!(stream.read_byte()) {
|
match try_io!(stream.read_byte()) {
|
||||||
SP => {
|
SP => {
|
||||||
@@ -446,7 +453,7 @@ pub fn read_uri<R: Reader>(stream: &mut R) -> HttpResult<uri::RequestUri> {
|
|||||||
CR | LF => {
|
CR | LF => {
|
||||||
return Err(HttpUriError)
|
return Err(HttpUriError)
|
||||||
},
|
},
|
||||||
b => s.push_char(b as char)
|
b => s.push(b as char)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user