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.
		
			
				
	
	
		
			24 lines
		
	
	
		
			568 B
		
	
	
	
		
			Rust
		
	
	
	
	
	
			
		
		
	
	
			24 lines
		
	
	
		
			568 B
		
	
	
	
		
			Rust
		
	
	
	
	
	
| #![deny(warnings)]
 | |
| #![feature(io, net)]
 | |
| extern crate hyper;
 | |
| extern crate env_logger;
 | |
| 
 | |
| use std::io::Write;
 | |
| use std::net::IpAddr;
 | |
| use hyper::server::{Request, Response};
 | |
| 
 | |
| static PHRASE: &'static [u8] = b"Hello World!";
 | |
| 
 | |
| fn hello(_: Request, res: Response) {
 | |
|     let mut res = res.start().unwrap();
 | |
|     res.write_all(PHRASE).unwrap();
 | |
|     res.end().unwrap();
 | |
| }
 | |
| 
 | |
| 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");
 | |
| }
 |