@@ -6,10 +6,10 @@ use std::io::net::ip::Ipv4Addr;
|
|||||||
static PHRASE: &'static [u8] = b"Hello World!";
|
static PHRASE: &'static [u8] = b"Hello World!";
|
||||||
|
|
||||||
fn hyper_handle(mut incoming: hyper::server::Incoming) {
|
fn hyper_handle(mut incoming: hyper::server::Incoming) {
|
||||||
let mut pool = TaskPool::new(100, || { proc(_) { } });
|
let mut pool = TaskPool::new(100);
|
||||||
|
|
||||||
for conn in incoming {
|
for conn in incoming {
|
||||||
pool.execute(proc(_) {
|
pool.execute(proc() {
|
||||||
let (_, res) = conn.open().unwrap();
|
let (_, res) = conn.open().unwrap();
|
||||||
let mut res = res.start().unwrap();
|
let mut res = res.start().unwrap();
|
||||||
res.write(PHRASE).unwrap();
|
res.write(PHRASE).unwrap();
|
||||||
@@ -21,4 +21,3 @@ fn hyper_handle(mut incoming: hyper::server::Incoming) {
|
|||||||
fn main() {
|
fn main() {
|
||||||
hyper::Server::http(Ipv4Addr(127, 0, 0, 1), 3000).listen(hyper_handle).unwrap();
|
hyper::Server::http(Ipv4Addr(127, 0, 0, 1), 3000).listen(hyper_handle).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
use std::fmt::{mod, Show};
|
use std::fmt::{mod, Show};
|
||||||
use std::from_str::FromStr;
|
use std::str::{FromStr, from_utf8};
|
||||||
use std::str::from_utf8;
|
|
||||||
use serialize::base64::{ToBase64, FromBase64, Standard, Config};
|
use serialize::base64::{ToBase64, FromBase64, Standard, Config};
|
||||||
use header::{Header, HeaderFormat};
|
use header::{Header, HeaderFormat};
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
use header::{Header, HeaderFormat};
|
use header::{Header, HeaderFormat};
|
||||||
use std::fmt::{mod, Show};
|
use std::fmt::{mod, Show};
|
||||||
use super::{from_comma_delimited, fmt_comma_delimited};
|
use super::{from_comma_delimited, fmt_comma_delimited};
|
||||||
use std::from_str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
/// The `Connection` header.
|
/// The `Connection` header.
|
||||||
#[deriving(Clone, PartialEq, Show)]
|
#[deriving(Clone, PartialEq, Show)]
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
use header::{Header, HeaderFormat};
|
use header::{Header, HeaderFormat};
|
||||||
use std::fmt::{mod, Show};
|
use std::fmt::{mod, Show};
|
||||||
use std::str::from_utf8;
|
use std::str::{from_utf8, from_str};
|
||||||
use std::from_str::from_str;
|
|
||||||
|
|
||||||
use cookie::Cookie;
|
use cookie::Cookie;
|
||||||
use cookie::CookieJar;
|
use cookie::CookieJar;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
use header::{Header, HeaderFormat};
|
use header::{Header, HeaderFormat};
|
||||||
use std::fmt::{mod, Show};
|
use std::fmt::{mod, Show};
|
||||||
use super::util::from_one_raw_str;
|
use super::util::from_one_raw_str;
|
||||||
use std::from_str::FromStr;
|
use std::str::FromStr;
|
||||||
use time::{Tm, strptime};
|
use time::{Tm, strptime};
|
||||||
|
|
||||||
// Egh, replace as soon as something better than time::Tm exists.
|
// Egh, replace as soon as something better than time::Tm exists.
|
||||||
|
|||||||
@@ -22,8 +22,7 @@ pub use self::server::Server;
|
|||||||
pub use self::set_cookie::SetCookie;
|
pub use self::set_cookie::SetCookie;
|
||||||
|
|
||||||
use std::fmt::{mod, Show};
|
use std::fmt::{mod, Show};
|
||||||
use std::from_str::FromStr;
|
use std::str::{FromStr, from_utf8};
|
||||||
use std::str::from_utf8;
|
|
||||||
|
|
||||||
macro_rules! bench_header(
|
macro_rules! bench_header(
|
||||||
($name:ident, $ty:ty, $value:expr) => {
|
($name:ident, $ty:ty, $value:expr) => {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use header::{Header, HeaderFormat};
|
use header::{Header, HeaderFormat};
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::from_str::FromStr;
|
use std::str::FromStr;
|
||||||
use super::{from_comma_delimited, fmt_comma_delimited};
|
use super::{from_comma_delimited, fmt_comma_delimited};
|
||||||
|
|
||||||
/// The `Transfer-Encoding` header.
|
/// The `Transfer-Encoding` header.
|
||||||
@@ -86,4 +86,3 @@ impl HeaderFormat for TransferEncoding {
|
|||||||
|
|
||||||
bench_header!(normal, TransferEncoding, { vec![b"chunked, gzip".to_vec()] })
|
bench_header!(normal, TransferEncoding, { vec![b"chunked, gzip".to_vec()] })
|
||||||
bench_header!(ext, TransferEncoding, { vec![b"ext".to_vec()] })
|
bench_header!(ext, TransferEncoding, { vec![b"ext".to_vec()] })
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
use header::{Header, HeaderFormat};
|
use header::{Header, HeaderFormat};
|
||||||
use std::fmt::{mod, Show};
|
use std::fmt::{mod, Show};
|
||||||
use super::{from_comma_delimited, fmt_comma_delimited};
|
use super::{from_comma_delimited, fmt_comma_delimited};
|
||||||
use std::from_str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
/// The `Upgrade` header.
|
/// The `Upgrade` header.
|
||||||
#[deriving(Clone, PartialEq, Show)]
|
#[deriving(Clone, PartialEq, Show)]
|
||||||
@@ -52,4 +52,3 @@ impl HeaderFormat for Upgrade {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bench_header!(bench, Upgrade, { vec![b"HTTP/2.0, RTA/x11, websocket".to_vec()] })
|
bench_header!(bench, Upgrade, { vec![b"HTTP/2.0, RTA/x11, websocket".to_vec()] })
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
//! Utility functions for Header implementations.
|
//! Utility functions for Header implementations.
|
||||||
|
|
||||||
use std::from_str::FromStr;
|
use std::str::{FromStr, from_utf8};
|
||||||
use std::str::from_utf8;
|
|
||||||
|
|
||||||
/// Utility function that reads a single raw string when parsing a header
|
/// Utility function that reads a single raw string when parsing a header
|
||||||
pub fn from_one_raw_str<T: FromStr>(raw: &[Vec<u8>]) -> Option<T> {
|
pub fn from_one_raw_str<T: FromStr>(raw: &[Vec<u8>]) -> Option<T> {
|
||||||
|
|||||||
@@ -457,7 +457,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
fn parse_header(raw: &[Vec<u8>]) -> Option<CrazyLength> {
|
fn parse_header(raw: &[Vec<u8>]) -> Option<CrazyLength> {
|
||||||
use std::str::from_utf8;
|
use std::str::from_utf8;
|
||||||
use std::from_str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
if raw.len() != 1 {
|
if raw.len() != 1 {
|
||||||
return None;
|
return None;
|
||||||
@@ -551,4 +551,3 @@ mod tests {
|
|||||||
assert_eq!(headers.len(), 0);
|
assert_eq!(headers.len(), 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
//! The HTTP request method
|
//! The HTTP request method
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::from_str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
/// The Request Method (VERB)
|
/// The Request Method (VERB)
|
||||||
///
|
///
|
||||||
|
|||||||
Reference in New Issue
Block a user