#![feature(os, io)]
extern crate hyper;

use std::os;
use std::old_io::stdout;
use std::old_io::util::copy;

use hyper::Client;

fn main() {
    let args = os::args();
    match args.len() {
        2 => (),
        _ => {
            println!("Usage: client <url>");
            return;
        }
    };

    let url = &*args[1];

    let mut client = Client::new();

    let mut 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);
    match copy(&mut res, &mut stdout()) {
        Ok(..) => (),
        Err(e) => panic!("Stream failure: {:?}", e)
    };

}

#![feature(env, os, io)]
extern crate hyper;

use std::env;
use std::old_io::stdout;
use std::old_io::util::copy;

use hyper::Client;

fn main() {
    let url = match env::args().nth(1) {
        Some(url) => url,
        None => {
            println!("Usage: client <url>");
            return;
        }
    };

    let url = match url.to_str() {
        Some(url) => url,
        None => {
            println!("Url contains invalid unicode");
            return;
        }
    };

    let mut client = Client::new();

    let mut 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);
    match copy(&mut res, &mut stdout()) {
        Ok(..) => (),
        Err(e) => panic!("Stream failure: {:?}", e)
    };

}

Stop using deprecated std::os::args in example
chore(examples): Stop using deprecated std::os::args in example

As per this compiler warning

"warning: use of deprecated item: use std::env::args() instead, #[warn(deprecated)] on by default"
