Update the client API to statically track headers and move constructors
The client Request now uses the same system as a server Response to track the write status of headers, and the API has been updated accordingly. Additionally, the Request constructors have been moved onto the Request object instead of being top-level hyper functions, as this better namespaces the client and Server.
This commit is contained in:
committed by
Sean McArthur
parent
38a47889d9
commit
d5c6f33c34
@@ -5,6 +5,7 @@ use std::io::stdout;
|
||||
use std::io::util::copy;
|
||||
|
||||
use hyper::Url;
|
||||
use hyper::client::Request;
|
||||
|
||||
fn main() {
|
||||
let args = os::args();
|
||||
@@ -25,12 +26,15 @@ fn main() {
|
||||
};
|
||||
|
||||
|
||||
let req = match hyper::get(url) {
|
||||
let req = match Request::get(url) {
|
||||
Ok(req) => req,
|
||||
Err(err) => fail!("Failed to connect: {}", err)
|
||||
};
|
||||
let mut res = req.send().unwrap();
|
||||
|
||||
|
||||
let mut res = req
|
||||
.start().ok().expect("Error writing Headers.")
|
||||
.send().ok().expect("Error sending Request.");
|
||||
|
||||
println!("Response: {}", res.status);
|
||||
println!("{}", res.headers);
|
||||
match copy(&mut res, &mut stdout()) {
|
||||
|
||||
Reference in New Issue
Block a user