Misc renames (#202)

This patch renames a number of types and functions making
the API more consistent.

* `Server` -> `Connection`
* `Client` -> `SendRequest`
* `Respond` -> `SendResponse`.

It also moves the handshake fns off of `Connection` and make
them free fns in the module. And `Connection::builder` is removed
in favor of `Builder::new`.
This commit is contained in:
Carl Lerche
2018-01-02 17:02:17 -08:00
committed by GitHub
parent 26e7a2d416
commit d0b5b6246a
17 changed files with 299 additions and 306 deletions

View File

@@ -20,7 +20,7 @@ fn send_recv_headers_only() {
.read(&[0, 0, 1, 1, 5, 0, 0, 0, 1, 0x89])
.build();
let (mut client, mut h2) = Client::handshake(mock).wait().unwrap();
let (mut client, mut h2) = client::handshake(mock).wait().unwrap();
// Send the request
let request = Request::builder()
@@ -62,7 +62,7 @@ fn send_recv_data() {
])
.build();
let (mut client, mut h2) = Client::builder().handshake(mock).wait().unwrap();
let (mut client, mut h2) = client::Builder::new().handshake(mock).wait().unwrap();
let request = Request::builder()
.method(Method::POST)
@@ -119,7 +119,7 @@ fn send_headers_recv_data_single_frame() {
])
.build();
let (mut client, mut h2) = Client::handshake(mock).wait().unwrap();
let (mut client, mut h2) = client::handshake(mock).wait().unwrap();
// Send the request
let request = Request::builder()
@@ -154,7 +154,7 @@ fn closed_streams_are_released() {
let _ = ::env_logger::init();
let (io, srv) = mock::new();
let h2 = Client::handshake(io).unwrap().and_then(|(mut client, h2)| {
let h2 = client::handshake(io).unwrap().and_then(|(mut client, h2)| {
let request = Request::get("https://example.com/").body(()).unwrap();
// Send request
@@ -199,7 +199,7 @@ fn errors_if_recv_frame_exceeds_max_frame_size() {
let _ = ::env_logger::init();
let (io, mut srv) = mock::new();
let h2 = Client::handshake(io).unwrap().and_then(|(mut client, h2)| {
let h2 = client::handshake(io).unwrap().and_then(|(mut client, h2)| {
let request = Request::builder()
.method(Method::GET)
.uri("https://example.com/")
@@ -254,7 +254,7 @@ fn configure_max_frame_size() {
let _ = ::env_logger::init();
let (io, mut srv) = mock::new();
let h2 = Client::builder()
let h2 = client::Builder::new()
.max_frame_size(16_384 * 2)
.handshake::<_, Bytes>(io)
.expect("handshake")
@@ -325,7 +325,7 @@ fn recv_goaway_finishes_processed_streams() {
.recv_frame(frames::go_away(0));
//.close();
let h2 = Client::handshake(io)
let h2 = client::handshake(io)
.expect("handshake")
.and_then(|(mut client, h2)| {
let request = Request::builder()
@@ -396,7 +396,7 @@ fn recv_next_stream_id_updated_by_malformed_headers() {
.recv_frame(frames::go_away(1).protocol_error())
.close();
let srv = Server::handshake(io)
let srv = server::handshake(io)
.expect("handshake")
.and_then(|srv| srv.into_future().then(|res| {
let (err, _) = res.unwrap_err();
@@ -429,7 +429,7 @@ fn skipped_stream_ids_are_implicitly_closed() {
// implicitly closed.
.send_frame(frames::headers(3).response(200));
let h2 = Client::builder()
let h2 = client::Builder::new()
.initial_stream_id(5)
.handshake::<_, Bytes>(io)
.expect("handshake")
@@ -491,7 +491,7 @@ fn send_rst_stream_allows_recv_data() {
.ping_pong([1; 8])
.close();
let client = Client::handshake(io)
let client = client::handshake(io)
.expect("handshake")
.and_then(|(mut client, conn)| {
let request = Request::builder()
@@ -540,7 +540,7 @@ fn send_rst_stream_allows_recv_trailers() {
.ping_pong([1; 8])
.close();
let client = Client::handshake(io)
let client = client::handshake(io)
.expect("handshake")
.and_then(|(mut client, conn)| {
let request = Request::builder()
@@ -591,7 +591,7 @@ fn rst_stream_expires() {
.recv_frame(frames::go_away(0).protocol_error())
.close();
let client = Client::builder()
let client = client::Builder::new()
.reset_stream_duration(Duration::from_millis(10))
.handshake::<_, Bytes>(io)
.expect("handshake")
@@ -663,7 +663,7 @@ fn rst_stream_max() {
.recv_frame(frames::go_away(0).protocol_error())
.close();
let client = Client::builder()
let client = client::Builder::new()
.max_concurrent_reset_streams(1)
.handshake::<_, Bytes>(io)
.expect("handshake")
@@ -744,7 +744,7 @@ fn reserved_state_recv_window_update() {
.ping_pong([1; 8])
.close();
let client = Client::handshake(io)
let client = client::handshake(io)
.expect("handshake")
.and_then(|(mut client, conn)| {
let request = Request::builder()