Use rustfmt to enforce consistent formatting
This change adds a .rustfmt.toml that includes ALL supported settings, 12 of which we have overridden to attempt to cater to our own proclivities. rustfmt is checked in the rust-nightly CI job.
This commit is contained in:
@@ -1,20 +1,20 @@
|
||||
extern crate env_logger;
|
||||
extern crate futures;
|
||||
extern crate h2;
|
||||
extern crate http;
|
||||
extern crate futures;
|
||||
extern crate io_dump;
|
||||
extern crate rustls;
|
||||
extern crate tokio_core;
|
||||
extern crate tokio_rustls;
|
||||
extern crate webpki_roots;
|
||||
extern crate io_dump;
|
||||
extern crate env_logger;
|
||||
|
||||
use h2::client::Client;
|
||||
|
||||
use http::{Request, Method};
|
||||
use futures::*;
|
||||
use http::{Method, Request};
|
||||
|
||||
use tokio_core::reactor;
|
||||
use tokio_core::net::TcpStream;
|
||||
use tokio_core::reactor;
|
||||
|
||||
use rustls::Session;
|
||||
use tokio_rustls::ClientConfigExt;
|
||||
@@ -27,26 +27,30 @@ pub fn main() {
|
||||
let _ = env_logger::init();
|
||||
|
||||
let tls_client_config = std::sync::Arc::new({
|
||||
let mut c = rustls::ClientConfig::new();
|
||||
c.root_store.add_server_trust_anchors(&webpki_roots::TLS_SERVER_ROOTS);
|
||||
c.alpn_protocols.push(ALPN_H2.to_owned());
|
||||
c
|
||||
});
|
||||
let mut c = rustls::ClientConfig::new();
|
||||
c.root_store.add_server_trust_anchors(&webpki_roots::TLS_SERVER_ROOTS);
|
||||
c.alpn_protocols.push(ALPN_H2.to_owned());
|
||||
c
|
||||
});
|
||||
|
||||
// Sync DNS resolution.
|
||||
let addr = "http2.akamai.com:443".to_socket_addrs()
|
||||
.unwrap().next().unwrap();
|
||||
let addr = "http2.akamai.com:443"
|
||||
.to_socket_addrs()
|
||||
.unwrap()
|
||||
.next()
|
||||
.unwrap();
|
||||
|
||||
println!("ADDR: {:?}", addr);
|
||||
|
||||
let mut core = reactor::Core::new().unwrap();;
|
||||
let mut core = reactor::Core::new().unwrap();
|
||||
let handle = core.handle();
|
||||
|
||||
let tcp = TcpStream::connect(&addr, &handle);
|
||||
|
||||
let tcp = tcp.then(|res| {
|
||||
let tcp = res.unwrap();
|
||||
tls_client_config.connect_async("http2.akamai.com", tcp)
|
||||
tls_client_config
|
||||
.connect_async("http2.akamai.com", tcp)
|
||||
.then(|res| {
|
||||
let tls = res.unwrap();
|
||||
let negotiated_protcol = {
|
||||
@@ -67,7 +71,8 @@ pub fn main() {
|
||||
let request = Request::builder()
|
||||
.method(Method::GET)
|
||||
.uri("https://http2.akamai.com/")
|
||||
.body(()).unwrap();
|
||||
.body(())
|
||||
.unwrap();
|
||||
|
||||
let stream = h2.request(request, true).unwrap();
|
||||
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
extern crate bytes;
|
||||
extern crate env_logger;
|
||||
extern crate futures;
|
||||
extern crate h2;
|
||||
extern crate http;
|
||||
extern crate bytes;
|
||||
extern crate futures;
|
||||
extern crate tokio_core;
|
||||
extern crate io_dump;
|
||||
extern crate env_logger;
|
||||
extern crate tokio_core;
|
||||
|
||||
use h2::client::{Client, Body};
|
||||
use h2::client::{Body, Client};
|
||||
|
||||
use http::*;
|
||||
use futures::*;
|
||||
use bytes::*;
|
||||
use futures::*;
|
||||
use http::*;
|
||||
|
||||
use tokio_core::reactor;
|
||||
use tokio_core::net::TcpStream;
|
||||
use tokio_core::reactor;
|
||||
|
||||
struct Process {
|
||||
body: Body<Bytes>,
|
||||
@@ -49,52 +49,51 @@ impl Future for Process {
|
||||
pub fn main() {
|
||||
let _ = env_logger::init();
|
||||
|
||||
let mut core = reactor::Core::new().unwrap();;
|
||||
let mut core = reactor::Core::new().unwrap();
|
||||
let handle = core.handle();
|
||||
|
||||
let tcp = TcpStream::connect(
|
||||
&"127.0.0.1:5928".parse().unwrap(),
|
||||
&handle);
|
||||
let tcp = TcpStream::connect(&"127.0.0.1:5928".parse().unwrap(), &handle);
|
||||
|
||||
let tcp = tcp.then(|res| {
|
||||
let tcp = io_dump::Dump::to_stdout(res.unwrap());
|
||||
Client::handshake(tcp)
|
||||
})
|
||||
.then(|res| {
|
||||
let mut client = res.unwrap();
|
||||
}).then(|res| {
|
||||
let mut client = res.unwrap();
|
||||
|
||||
println!("sending request");
|
||||
println!("sending request");
|
||||
|
||||
let request = Request::builder()
|
||||
.uri("https://http2.akamai.com/")
|
||||
.body(()).unwrap();
|
||||
let request = Request::builder()
|
||||
.uri("https://http2.akamai.com/")
|
||||
.body(())
|
||||
.unwrap();
|
||||
|
||||
let mut trailers = HeaderMap::new();
|
||||
trailers.insert("zomg", "hello".parse().unwrap());
|
||||
let mut trailers = HeaderMap::new();
|
||||
trailers.insert("zomg", "hello".parse().unwrap());
|
||||
|
||||
let mut stream = client.request(request, false).unwrap();
|
||||
let mut stream = client.request(request, false).unwrap();
|
||||
|
||||
// send trailers
|
||||
stream.send_trailers(trailers).unwrap();
|
||||
// send trailers
|
||||
stream.send_trailers(trailers).unwrap();
|
||||
|
||||
// Spawn a task to run the client...
|
||||
handle.spawn(client.map_err(|e| println!("GOT ERR={:?}", e)));
|
||||
// Spawn a task to run the client...
|
||||
handle.spawn(client.map_err(|e| println!("GOT ERR={:?}", e)));
|
||||
|
||||
stream.and_then(|response| {
|
||||
println!("GOT RESPONSE: {:?}", response);
|
||||
stream
|
||||
.and_then(|response| {
|
||||
println!("GOT RESPONSE: {:?}", response);
|
||||
|
||||
// Get the body
|
||||
let (_, body) = response.into_parts();
|
||||
// Get the body
|
||||
let (_, body) = response.into_parts();
|
||||
|
||||
Process {
|
||||
body,
|
||||
trailers: false,
|
||||
}
|
||||
}).map_err(|e| {
|
||||
println!("GOT ERR={:?}", e);
|
||||
})
|
||||
})
|
||||
;
|
||||
Process {
|
||||
body,
|
||||
trailers: false,
|
||||
}
|
||||
})
|
||||
.map_err(|e| {
|
||||
println!("GOT ERR={:?}", e);
|
||||
})
|
||||
});
|
||||
|
||||
core.run(tcp).unwrap();
|
||||
}
|
||||
|
||||
@@ -1,28 +1,27 @@
|
||||
|
||||
extern crate bytes;
|
||||
extern crate env_logger;
|
||||
extern crate futures;
|
||||
extern crate h2;
|
||||
extern crate http;
|
||||
extern crate bytes;
|
||||
extern crate futures;
|
||||
extern crate tokio_core;
|
||||
extern crate env_logger;
|
||||
|
||||
use h2::server::Server;
|
||||
|
||||
use http::*;
|
||||
use bytes::*;
|
||||
use futures::*;
|
||||
use http::*;
|
||||
|
||||
use tokio_core::reactor;
|
||||
use tokio_core::net::TcpListener;
|
||||
use tokio_core::reactor;
|
||||
|
||||
pub fn main() {
|
||||
let _ = env_logger::init();
|
||||
|
||||
let mut core = reactor::Core::new().unwrap();;
|
||||
let mut core = reactor::Core::new().unwrap();
|
||||
let handle = core.handle();
|
||||
|
||||
let listener = TcpListener::bind(
|
||||
&"127.0.0.1:5928".parse().unwrap(),
|
||||
&handle).unwrap();
|
||||
let listener = TcpListener::bind(&"127.0.0.1:5928".parse().unwrap(), &handle).unwrap();
|
||||
|
||||
println!("listening on {:?}", listener.local_addr());
|
||||
|
||||
@@ -37,9 +36,7 @@ pub fn main() {
|
||||
conn.for_each(|(request, mut stream)| {
|
||||
println!("GOT request: {:?}", request);
|
||||
|
||||
let response = Response::builder()
|
||||
.status(StatusCode::OK)
|
||||
.body(()).unwrap();
|
||||
let response = Response::builder().status(StatusCode::OK).body(()).unwrap();
|
||||
|
||||
if let Err(e) = stream.send_response(response, false) {
|
||||
println!(" error responding; err={:?}", e);
|
||||
@@ -60,9 +57,10 @@ pub fn main() {
|
||||
|
||||
Ok(())
|
||||
}).and_then(|_| {
|
||||
println!("~~~~~~~~~~~~~~~~~~~~~~~~~~~ H2 connection CLOSE !!!!!! ~~~~~~~~~~~");
|
||||
Ok(())
|
||||
})
|
||||
println!("~~~~~~~~~~~~~~~~~~~~~~~~~~~ H2 connection CLOSE !!!!!! \
|
||||
~~~~~~~~~~~");
|
||||
Ok(())
|
||||
})
|
||||
})
|
||||
.then(|res| {
|
||||
if let Err(e) = res {
|
||||
@@ -70,8 +68,7 @@ pub fn main() {
|
||||
}
|
||||
|
||||
Ok(())
|
||||
})
|
||||
;
|
||||
});
|
||||
|
||||
handle.spawn(connection);
|
||||
Ok(())
|
||||
|
||||
@@ -1,28 +1,27 @@
|
||||
|
||||
extern crate bytes;
|
||||
extern crate env_logger;
|
||||
extern crate futures;
|
||||
extern crate h2;
|
||||
extern crate http;
|
||||
extern crate bytes;
|
||||
extern crate futures;
|
||||
extern crate tokio_core;
|
||||
extern crate env_logger;
|
||||
|
||||
use h2::server::Server;
|
||||
|
||||
use http::*;
|
||||
use bytes::*;
|
||||
use futures::*;
|
||||
use http::*;
|
||||
|
||||
use tokio_core::reactor;
|
||||
use tokio_core::net::TcpListener;
|
||||
use tokio_core::reactor;
|
||||
|
||||
pub fn main() {
|
||||
let _ = env_logger::init();
|
||||
|
||||
let mut core = reactor::Core::new().unwrap();;
|
||||
let mut core = reactor::Core::new().unwrap();
|
||||
let handle = core.handle();
|
||||
|
||||
let listener = TcpListener::bind(
|
||||
&"127.0.0.1:5928".parse().unwrap(),
|
||||
&handle).unwrap();
|
||||
let listener = TcpListener::bind(&"127.0.0.1:5928".parse().unwrap(), &handle).unwrap();
|
||||
|
||||
println!("listening on {:?}", listener.local_addr());
|
||||
|
||||
@@ -37,9 +36,7 @@ pub fn main() {
|
||||
conn.for_each(|(request, mut stream)| {
|
||||
println!("GOT request: {:?}", request);
|
||||
|
||||
let response = Response::builder()
|
||||
.status(StatusCode::OK)
|
||||
.body(()).unwrap();
|
||||
let response = Response::builder().status(StatusCode::OK).body(()).unwrap();
|
||||
|
||||
if let Err(e) = stream.send_response(response, false) {
|
||||
println!(" error responding; err={:?}", e);
|
||||
@@ -52,9 +49,10 @@ pub fn main() {
|
||||
|
||||
Ok(())
|
||||
}).and_then(|_| {
|
||||
println!("~~~~~~~~~~~~~~~~~~~~~~~~~~~ H2 connection CLOSE !!!!!! ~~~~~~~~~~~");
|
||||
Ok(())
|
||||
})
|
||||
println!("~~~~~~~~~~~~~~~~~~~~~~~~~~~ H2 connection CLOSE !!!!!! \
|
||||
~~~~~~~~~~~");
|
||||
Ok(())
|
||||
})
|
||||
})
|
||||
.then(|res| {
|
||||
if let Err(e) = res {
|
||||
@@ -62,8 +60,7 @@ pub fn main() {
|
||||
}
|
||||
|
||||
Ok(())
|
||||
})
|
||||
;
|
||||
});
|
||||
|
||||
handle.spawn(connection);
|
||||
Ok(())
|
||||
|
||||
Reference in New Issue
Block a user