@@ -5,15 +5,15 @@ use std::net::SocketAddr;
5
5
use hyper:: body:: HttpBody as _;
6
6
use hyper:: server:: conn:: Http ;
7
7
use hyper:: service:: service_fn;
8
- use hyper:: { Body , Method , Request , Response , StatusCode } ;
8
+ use hyper:: { Method , Recv , Request , Response , StatusCode } ;
9
9
use tokio:: net:: TcpListener ;
10
10
11
11
/// This is our service handler. It receives a Request, routes on its
12
12
/// path, and returns a Future of a Response.
13
- async fn echo ( req : Request < Body > ) -> Result < Response < Body > , hyper:: Error > {
13
+ async fn echo ( req : Request < Recv > ) -> Result < Response < Recv > , hyper:: Error > {
14
14
match ( req. method ( ) , req. uri ( ) . path ( ) ) {
15
15
// Serve some instructions at /
16
- ( & Method :: GET , "/" ) => Ok ( Response :: new ( Body :: from (
16
+ ( & Method :: GET , "/" ) => Ok ( Response :: new ( Recv :: from (
17
17
"Try POSTing data to /echo such as: `curl localhost:3000/echo -XPOST -d 'hello world'`" ,
18
18
) ) ) ,
19
19
@@ -43,15 +43,15 @@ async fn echo(req: Request<Body>) -> Result<Response<Body>, hyper::Error> {
43
43
// 64kbs of data.
44
44
let max = req. body ( ) . size_hint ( ) . upper ( ) . unwrap_or ( u64:: MAX ) ;
45
45
if max > 1024 * 64 {
46
- let mut resp = Response :: new ( Body :: from ( "Body too big" ) ) ;
46
+ let mut resp = Response :: new ( Recv :: from ( "Body too big" ) ) ;
47
47
* resp. status_mut ( ) = hyper:: StatusCode :: PAYLOAD_TOO_LARGE ;
48
48
return Ok ( resp) ;
49
49
}
50
50
51
51
let whole_body = hyper:: body:: to_bytes ( req. into_body ( ) ) . await ?;
52
52
53
53
let reversed_body = whole_body. iter ( ) . rev ( ) . cloned ( ) . collect :: < Vec < u8 > > ( ) ;
54
- Ok ( Response :: new ( Body :: from ( reversed_body) ) )
54
+ Ok ( Response :: new ( Recv :: from ( reversed_body) ) )
55
55
}
56
56
57
57
// Return the 404 Not Found for other routes.
0 commit comments