test(benches): fix deprecated futures usage in benches
This commit is contained in:
@@ -8,7 +8,7 @@ extern crate tokio_core;
|
||||
|
||||
use std::net::SocketAddr;
|
||||
|
||||
use futures::{Future, Stream};
|
||||
use futures::{future, Future, Stream};
|
||||
use tokio_core::reactor::{Core, Handle};
|
||||
use tokio_core::net::TcpListener;
|
||||
|
||||
@@ -76,9 +76,9 @@ impl Service for Hello {
|
||||
type Request = server::Request;
|
||||
type Response = server::Response;
|
||||
type Error = hyper::Error;
|
||||
type Future = ::futures::Finished<Self::Response, hyper::Error>;
|
||||
type Future = future::FutureResult<Self::Response, hyper::Error>;
|
||||
fn call(&self, _req: Self::Request) -> Self::Future {
|
||||
::futures::finished(
|
||||
future::ok(
|
||||
server::Response::new()
|
||||
.with_header(ContentLength(PHRASE.len() as u64))
|
||||
.with_header(ContentType::plaintext())
|
||||
@@ -94,9 +94,13 @@ fn spawn_hello(handle: &Handle) -> SocketAddr {
|
||||
let addr = listener.local_addr().unwrap();
|
||||
|
||||
let handle2 = handle.clone();
|
||||
let http = hyper::server::Http::new();
|
||||
handle.spawn(listener.incoming().for_each(move |(socket, addr)| {
|
||||
http.bind_connection(&handle2, socket, addr, Hello);
|
||||
let http = hyper::server::Http::<hyper::Chunk>::new();
|
||||
handle.spawn(listener.incoming().for_each(move |(socket, _addr)| {
|
||||
handle2.spawn(
|
||||
http.serve_connection(socket, Hello)
|
||||
.map(|_| ())
|
||||
.map_err(|_| ())
|
||||
);
|
||||
Ok(())
|
||||
}).then(|_| Ok(())));
|
||||
return addr
|
||||
|
||||
@@ -9,7 +9,7 @@ use std::io::{Read, Write};
|
||||
use std::net::{TcpListener, TcpStream};
|
||||
use std::sync::mpsc;
|
||||
|
||||
use futures::Future;
|
||||
use futures::{future, Future};
|
||||
use futures::sync::oneshot;
|
||||
|
||||
use hyper::header::{ContentLength, ContentType, TransferEncoding};
|
||||
@@ -102,9 +102,9 @@ impl Service for FixedSizeSmallPayload {
|
||||
type Request = server::Request;
|
||||
type Response = server::Response;
|
||||
type Error = hyper::Error;
|
||||
type Future = ::futures::Finished<Self::Response, hyper::Error>;
|
||||
type Future = future::FutureResult<Self::Response, hyper::Error>;
|
||||
fn call(&self, _req: Self::Request) -> Self::Future {
|
||||
::futures::finished(
|
||||
future::ok(
|
||||
server::Response::new()
|
||||
.with_header(ContentLength("Hello, World!".len() as u64))
|
||||
.with_header(ContentType::plaintext())
|
||||
@@ -119,9 +119,9 @@ impl Service for ChunkedSmallPayload {
|
||||
type Request = server::Request;
|
||||
type Response = server::Response;
|
||||
type Error = hyper::Error;
|
||||
type Future = ::futures::Finished<Self::Response, hyper::Error>;
|
||||
type Future = future::FutureResult<Self::Response, hyper::Error>;
|
||||
fn call(&self, _req: Self::Request) -> Self::Future {
|
||||
::futures::finished(
|
||||
future::ok(
|
||||
server::Response::new()
|
||||
.with_header(TransferEncoding::chunked())
|
||||
.with_header(ContentType::plaintext())
|
||||
@@ -136,9 +136,9 @@ impl Service for ChunkedLargePayload {
|
||||
type Request = server::Request;
|
||||
type Response = server::Response;
|
||||
type Error = hyper::Error;
|
||||
type Future = ::futures::Finished<Self::Response, hyper::Error>;
|
||||
type Future = future::FutureResult<Self::Response, hyper::Error>;
|
||||
fn call(&self, _req: Self::Request) -> Self::Future {
|
||||
::futures::finished(
|
||||
future::ok(
|
||||
server::Response::new()
|
||||
.with_header(TransferEncoding::chunked())
|
||||
.with_header(ContentType::plaintext())
|
||||
|
||||
@@ -971,11 +971,10 @@ fn max_buf_size() {
|
||||
let mut tcp = connect(&addr);
|
||||
tcp.write_all(b"POST /").expect("write 1");
|
||||
tcp.write_all(&vec![b'a'; MAX]).expect("write 2");
|
||||
tcp.write_all(b" HTTP/1.1\r\n\r\n").expect("write 3");
|
||||
let mut buf = [0; 256];
|
||||
tcp.read(&mut buf).expect("read 1");
|
||||
|
||||
let expected = "HTTP/1.1 400 ";
|
||||
let expected = "HTTP/1.1 431 ";
|
||||
assert_eq!(s(&buf[..expected.len()]), expected);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user