perf(http): changes http parsing to use httparse crate

httparse is a http1 stateless push parser. This not only speeds up
parsing right now with sync io, but will also be useful for when we get
async io, since it's push based instead of pull.

BREAKING CHANGE: Several public functions and types in the `http` module
  have been removed. They have been replaced with 2 methods that handle
  all of the http1 parsing.
This commit is contained in:
Sean McArthur
2015-03-12 14:01:52 -07:00
parent 003b6551cf
commit b87bb20f0c
15 changed files with 358 additions and 731 deletions

View File

@@ -1,11 +1,15 @@
#![deny(warnings)]
extern crate hyper;
extern crate env_logger;
use std::env;
use hyper::Client;
fn main() {
env_logger::init().unwrap();
let url = match env::args().nth(1) {
Some(url) => url,
None => {

View File

@@ -1,6 +1,7 @@
#![deny(warnings)]
#![feature(io, net)]
extern crate hyper;
extern crate env_logger;
use std::io::Write;
use std::net::IpAddr;
@@ -15,6 +16,7 @@ fn hello(_: Request, res: Response) {
}
fn main() {
env_logger::init().unwrap();
let _listening = hyper::Server::http(hello)
.listen(IpAddr::new_v4(127, 0, 0, 1), 3000).unwrap();
println!("Listening on http://127.0.0.1:3000");

View File

@@ -1,7 +1,7 @@
#![deny(warnings)]
#![feature(io, net)]
extern crate hyper;
#[macro_use] extern crate log;
extern crate env_logger;
use std::io::{Write, copy};
use std::net::IpAddr;
@@ -15,7 +15,7 @@ macro_rules! try_return(
($e:expr) => {{
match $e {
Ok(v) => v,
Err(e) => { error!("Error: {}", e); return; }
Err(e) => { println!("Error: {}", e); return; }
}
}}
);
@@ -51,6 +51,7 @@ fn echo(mut req: Request, mut res: Response) {
}
fn main() {
env_logger::init().unwrap();
let server = Server::http(echo);
let _guard = server.listen(IpAddr::new_v4(127, 0, 0, 1), 1337).unwrap();
println!("Listening on http://127.0.0.1:1337");