-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #448 from mlalic/http2-initial
feat(client): initial support for HTTP/2
- Loading branch information
Showing
11 changed files
with
1,507 additions
and
188 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#![deny(warnings)] | ||
extern crate hyper; | ||
|
||
extern crate env_logger; | ||
|
||
use std::env; | ||
use std::io; | ||
|
||
use hyper::Client; | ||
use hyper::header::Connection; | ||
use hyper::http2; | ||
|
||
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::with_protocol(http2::new_protocol()); | ||
|
||
// `Connection: Close` is not a valid header for HTTP/2, but the client handles it gracefully. | ||
let mut res = client.get(&*url) | ||
.header(Connection::close()) | ||
.send().unwrap(); | ||
|
||
println!("Response: {}", res.status); | ||
println!("Headers:\n{}", res.headers); | ||
io::copy(&mut res, &mut io::stdout()).unwrap(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.