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.
		
			
				
	
	
		
			32 lines
		
	
	
		
			641 B
		
	
	
	
		
			Rust
		
	
	
	
	
	
			
		
		
	
	
			32 lines
		
	
	
		
			641 B
		
	
	
	
		
			Rust
		
	
	
	
	
	
| #![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 => {
 | |
|             println!("Usage: client <url>");
 | |
|             return;
 | |
|         }
 | |
|     };
 | |
| 
 | |
|     let mut client = Client::new();
 | |
| 
 | |
|     let res = match client.get(&*url).send() {
 | |
|         Ok(res) => res,
 | |
|         Err(err) => panic!("Failed to connect: {:?}", err)
 | |
|     };
 | |
| 
 | |
|     println!("Response: {}", res.status);
 | |
|     println!("Headers:\n{}", res.headers);
 | |
|     //TODO: add copy back when std::stdio impls std::io::Write.
 | |
| }
 |