File tree 10 files changed +49
-36
lines changed
outbound/src/http/logical
10 files changed +49
-36
lines changed Original file line number Diff line number Diff line change @@ -21,10 +21,12 @@ where
21
21
}
22
22
23
23
http:: Method :: PUT => {
24
- #[ allow( deprecated) ] // linkerd/linkerd2#8733
25
- let body = hyper:: body:: aggregate ( req. into_body ( ) )
24
+ let body = req
25
+ . into_body ( )
26
+ . collect ( )
26
27
. await
27
- . map_err ( |e| io:: Error :: new ( io:: ErrorKind :: Other , e) ) ?;
28
+ . map_err ( |e| io:: Error :: new ( io:: ErrorKind :: Other , e) ) ?
29
+ . aggregate ( ) ;
28
30
match level. set_from ( body. chunk ( ) ) {
29
31
Ok ( _) => mk_rsp ( StatusCode :: NO_CONTENT , Body :: empty ( ) ) ,
30
32
Err ( error) => {
Original file line number Diff line number Diff line change @@ -52,11 +52,11 @@ where
52
52
// If the request is a QUERY, use the request body
53
53
method if method. as_str ( ) == "QUERY" => {
54
54
// TODO(eliza): validate that the request has a content-length...
55
- #[ allow( deprecated) ] // linkerd/linkerd2#8733
56
55
let body = recover ! (
57
- hyper :: body :: aggregate ( req. into_body( ) )
56
+ http_body :: Body :: collect ( req. into_body( ) )
58
57
. await
59
- . map_err( Into :: into) ,
58
+ . map_err( Into :: into)
59
+ . map( http_body:: Collected :: aggregate) ,
60
60
"Reading log stream request body" ,
61
61
StatusCode :: BAD_REQUEST
62
62
) ;
Original file line number Diff line number Diff line change @@ -209,8 +209,7 @@ where
209
209
// just can't prove it.
210
210
let req = futures:: executor:: block_on ( async move {
211
211
let ( parts, body) = req. into_parts ( ) ;
212
- #[ allow( deprecated) ] // linkerd/linkerd2#8733
213
- let body = match hyper:: body:: to_bytes ( body) . await {
212
+ let body = match body. collect ( ) . await . map ( http_body:: Collected :: to_bytes) {
214
213
Ok ( body) => body,
215
214
Err ( _) => unreachable ! ( "body should not fail" ) ,
216
215
} ;
Original file line number Diff line number Diff line change @@ -482,14 +482,15 @@ mod http2 {
482
482
let res = fut. await . expect ( "beta response" ) ;
483
483
assert_eq ! ( res. status( ) , http:: StatusCode :: OK ) ;
484
484
485
- # [ allow ( deprecated ) ] // linkerd/linkerd2#8733
486
- let body = String :: from_utf8 (
487
- hyper :: body :: to_bytes ( res . into_body ( ) )
485
+ let body = {
486
+ let body = res . into_body ( ) ;
487
+ let body = http_body :: Body :: collect ( body )
488
488
. await
489
489
. unwrap ( )
490
- . to_vec ( ) ,
491
- )
492
- . unwrap ( ) ;
490
+ . to_bytes ( )
491
+ . to_vec ( ) ;
492
+ String :: from_utf8 ( body) . unwrap ( )
493
+ } ;
493
494
assert_eq ! ( body, "beta" ) ;
494
495
}
495
496
}
Original file line number Diff line number Diff line change @@ -129,9 +129,11 @@ impl TestBuilder {
129
129
async move {
130
130
// Read the entire body before responding, so that the
131
131
// client doesn't fail when writing it out.
132
- #[ allow( deprecated) ] // linkerd/linkerd2#8733
133
- let _body = hyper:: body:: to_bytes ( req. into_body ( ) ) . await ;
134
- tracing:: debug!( body = ?_body. as_ref( ) . map( |body| body. len( ) ) , "recieved body" ) ;
132
+ let body = http_body:: Body :: collect ( req. into_body ( ) )
133
+ . await
134
+ . map ( http_body:: Collected :: to_bytes) ;
135
+ let bytes = body. as_ref ( ) . map ( Bytes :: len) ;
136
+ tracing:: debug!( ?bytes, "recieved body" ) ;
135
137
Ok :: < _ , Error > ( if fail {
136
138
Response :: builder ( ) . status ( 533 ) . body ( "nope" . into ( ) ) . unwrap ( )
137
139
} else {
Original file line number Diff line number Diff line change @@ -48,14 +48,13 @@ async fn h2_exercise_goaways_connections() {
48
48
49
49
let bodies = resps
50
50
. into_iter ( )
51
- . map (
52
- #[ allow( deprecated) ] // linkerd/linkerd2#8733
53
- |resp| {
54
- hyper:: body:: aggregate ( resp. into_body ( ) )
55
- // Make sure the bodies weren't cut off
56
- . map_ok ( |buf| assert_eq ! ( buf. remaining( ) , RESPONSE_SIZE ) )
57
- } ,
58
- )
51
+ . map ( Response :: into_body)
52
+ . map ( |body| {
53
+ http_body:: Body :: collect ( body)
54
+ . map_ok ( http_body:: Collected :: aggregate)
55
+ // Make sure the bodies weren't cut off
56
+ . map_ok ( |buf| assert_eq ! ( buf. remaining( ) , RESPONSE_SIZE ) )
57
+ } )
59
58
. collect :: < Vec < _ > > ( ) ;
60
59
61
60
// See that the proxy gives us all the bodies.
Original file line number Diff line number Diff line change @@ -253,8 +253,12 @@ async fn grpc_headers_end() {
253
253
. unwrap ( ) ;
254
254
assert_eq ! ( res. status( ) , 200 ) ;
255
255
assert_eq ! ( res. headers( ) [ "grpc-status" ] , "1" ) ;
256
- #[ allow( deprecated) ] // linkerd/linkerd2#8733
257
- let bytes = hyper:: body:: to_bytes ( res. into_body ( ) ) . await . unwrap ( ) . len ( ) ;
256
+ let body = res. into_body ( ) ;
257
+ let bytes = http_body:: Body :: collect ( body)
258
+ . await
259
+ . unwrap ( )
260
+ . to_bytes ( )
261
+ . len ( ) ;
258
262
assert_eq ! ( bytes, 0 ) ;
259
263
260
264
let event = events. skip ( 2 ) . next ( ) . await . expect ( "2nd" ) . expect ( "stream" ) ;
Original file line number Diff line number Diff line change @@ -1304,10 +1304,13 @@ async fn metrics_compression() {
1304
1304
) ;
1305
1305
}
1306
1306
1307
- #[ allow( deprecated) ] // linkerd/linkerd2#8733
1308
- let mut body = hyper:: body:: aggregate ( resp. into_body ( ) )
1309
- . await
1310
- . expect ( "response body concat" ) ;
1307
+ let mut body = {
1308
+ let body = resp. into_body ( ) ;
1309
+ http_body:: Body :: collect ( body)
1310
+ . await
1311
+ . expect ( "response body concat" )
1312
+ . aggregate ( )
1313
+ } ;
1311
1314
let mut decoder = flate2:: read:: GzDecoder :: new ( std:: io:: Cursor :: new (
1312
1315
body. copy_to_bytes ( body. remaining ( ) ) ,
1313
1316
) ) ;
Original file line number Diff line number Diff line change @@ -144,10 +144,12 @@ async fn assert_rsp<T: std::fmt::Debug>(
144
144
{
145
145
let rsp = rsp. await . expect ( "response must not fail" ) ;
146
146
assert_eq ! ( rsp. status( ) , status, "expected status code to be {status}" ) ;
147
- #[ allow( deprecated) ] // linkerd/linkerd2#8733
148
- let body = hyper:: body:: to_bytes ( rsp. into_body ( ) )
147
+ let body = rsp
148
+ . into_body ( )
149
+ . collect ( )
149
150
. await
150
- . expect ( "body must not fail" ) ;
151
+ . expect ( "body must not fail" )
152
+ . to_bytes ( ) ;
151
153
assert_eq ! ( body, expected_body, "expected body to be {expected_body:?}" ) ;
152
154
}
153
155
Original file line number Diff line number Diff line change @@ -121,9 +121,10 @@ where
121
121
T : HttpBody ,
122
122
T :: Error : Into < Error > ,
123
123
{
124
- # [ allow ( deprecated ) ] // linkerd/linkerd2#8733
125
- let body = hyper :: body :: to_bytes ( body )
124
+ let body = body
125
+ . collect ( )
126
126
. await
127
+ . map ( http_body:: Collected :: to_bytes)
127
128
. map_err ( ContextError :: ctx ( "HTTP response body stream failed" ) ) ?;
128
129
let body = std:: str:: from_utf8 ( & body[ ..] )
129
130
. map_err ( ContextError :: ctx ( "converting body to string failed" ) ) ?
You can’t perform that action at this time.
0 commit comments