All instances of `old_io` and `old_path` were switched to use the new shiny `std::io`, `std::net`, and `std::path` modules. This means that `Request` and `Response` implement `Read` and `Write` now. Because of the changes to `TcpListener`, this also takes the opportunity to correct the method usage of `Server`. As with other languages/frameworks, the server is first created with a handler, and then a host/port is passed to a `listen` method. This reverses what `Server` used to do. Closes #347 BREAKING CHANGE: Check the docs. Everything was touched.
		
			
				
	
	
		
			28 lines
		
	
	
		
			579 B
		
	
	
	
		
			Rust
		
	
	
	
	
	
			
		
		
	
	
			28 lines
		
	
	
		
			579 B
		
	
	
	
		
			Rust
		
	
	
	
	
	
| #![feature(env)]
 | |
| extern crate hyper;
 | |
| 
 | |
| use std::env;
 | |
| 
 | |
| use hyper::Client;
 | |
| 
 | |
| fn main() {
 | |
|     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.
 | |
| }
 |