Merge pull request #122 from jgillich/str

from_str & TaskPool updates
This commit is contained in:
Sean McArthur
2014-11-17 11:16:47 -08:00
11 changed files with 12 additions and 20 deletions

View File

@@ -6,10 +6,10 @@ use std::io::net::ip::Ipv4Addr;
static PHRASE: &'static [u8] = b"Hello World!";
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 {
pool.execute(proc(_) {
pool.execute(proc() {
let (_, res) = conn.open().unwrap();
let mut res = res.start().unwrap();
res.write(PHRASE).unwrap();
@@ -21,4 +21,3 @@ fn hyper_handle(mut incoming: hyper::server::Incoming) {
fn main() {
hyper::Server::http(Ipv4Addr(127, 0, 0, 1), 3000).listen(hyper_handle).unwrap();
}

View File

@@ -1,6 +1,5 @@
use std::fmt::{mod, Show};
use std::from_str::FromStr;
use std::str::from_utf8;
use std::str::{FromStr, from_utf8};
use serialize::base64::{ToBase64, FromBase64, Standard, Config};
use header::{Header, HeaderFormat};

View File

@@ -1,7 +1,7 @@
use header::{Header, HeaderFormat};
use std::fmt::{mod, Show};
use super::{from_comma_delimited, fmt_comma_delimited};
use std::from_str::FromStr;
use std::str::FromStr;
/// The `Connection` header.
#[deriving(Clone, PartialEq, Show)]

View File

@@ -1,7 +1,6 @@
use header::{Header, HeaderFormat};
use std::fmt::{mod, Show};
use std::str::from_utf8;
use std::from_str::from_str;
use std::str::{from_utf8, from_str};
use cookie::Cookie;
use cookie::CookieJar;

View File

@@ -1,7 +1,7 @@
use header::{Header, HeaderFormat};
use std::fmt::{mod, Show};
use super::util::from_one_raw_str;
use std::from_str::FromStr;
use std::str::FromStr;
use time::{Tm, strptime};
// Egh, replace as soon as something better than time::Tm exists.

View File

@@ -22,8 +22,7 @@ pub use self::server::Server;
pub use self::set_cookie::SetCookie;
use std::fmt::{mod, Show};
use std::from_str::FromStr;
use std::str::from_utf8;
use std::str::{FromStr, from_utf8};
macro_rules! bench_header(
($name:ident, $ty:ty, $value:expr) => {

View File

@@ -1,6 +1,6 @@
use header::{Header, HeaderFormat};
use std::fmt;
use std::from_str::FromStr;
use std::str::FromStr;
use super::{from_comma_delimited, fmt_comma_delimited};
/// The `Transfer-Encoding` header.
@@ -86,4 +86,3 @@ impl HeaderFormat for TransferEncoding {
bench_header!(normal, TransferEncoding, { vec![b"chunked, gzip".to_vec()] })
bench_header!(ext, TransferEncoding, { vec![b"ext".to_vec()] })

View File

@@ -1,7 +1,7 @@
use header::{Header, HeaderFormat};
use std::fmt::{mod, Show};
use super::{from_comma_delimited, fmt_comma_delimited};
use std::from_str::FromStr;
use std::str::FromStr;
/// The `Upgrade` header.
#[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()] })

View File

@@ -1,7 +1,6 @@
//! Utility functions for Header implementations.
use std::from_str::FromStr;
use std::str::from_utf8;
use std::str::{FromStr, from_utf8};
/// 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> {

View File

@@ -457,7 +457,7 @@ mod tests {
}
fn parse_header(raw: &[Vec<u8>]) -> Option<CrazyLength> {
use std::str::from_utf8;
use std::from_str::FromStr;
use std::str::FromStr;
if raw.len() != 1 {
return None;
@@ -551,4 +551,3 @@ mod tests {
assert_eq!(headers.len(), 0);
}
}

View File

@@ -1,6 +1,6 @@
//! The HTTP request method
use std::fmt;
use std::from_str::FromStr;
use std::str::FromStr;
/// The Request Method (VERB)
///