@@ -27,7 +27,7 @@ use tokio::net::{TcpListener as TkTcpListener, TcpListener, TcpStream as TkTcpSt
2727
2828use hyper:: body:: HttpBody ;
2929use hyper:: server:: conn:: Http ;
30- use hyper:: service:: service_fn;
30+ use hyper:: service:: { service_fn, Service } ;
3131use hyper:: { Body , Method , Request , Response , StatusCode , Uri , Version } ;
3232
3333mod support;
@@ -2305,77 +2305,6 @@ fn http2_body_user_error_sends_reset_reason() {
23052305 assert_eq ! ( h2_err. reason( ) , Some ( h2:: Reason :: INADEQUATE_SECURITY ) ) ;
23062306}
23072307
2308- struct Http2ReadyErrorSvc ;
2309-
2310- impl tower_service:: Service < Request < Body > > for Http2ReadyErrorSvc {
2311- type Response = Response < Body > ;
2312- type Error = h2:: Error ;
2313- type Future = Box <
2314- dyn futures_core:: Future < Output = Result < Self :: Response , Self :: Error > >
2315- + Send
2316- + Sync
2317- + Unpin ,
2318- > ;
2319-
2320- fn poll_ready ( & mut self , _: & mut std:: task:: Context < ' _ > ) -> Poll < Result < ( ) , Self :: Error > > {
2321- Poll :: Ready ( Err :: < ( ) , _ > ( h2:: Error :: from (
2322- h2:: Reason :: INADEQUATE_SECURITY ,
2323- ) ) )
2324- }
2325-
2326- fn call ( & mut self , _: hyper:: Request < Body > ) -> Self :: Future {
2327- unreachable ! ( "poll_ready error should have shutdown conn" ) ;
2328- }
2329- }
2330-
2331- #[ tokio:: test]
2332- #[ ignore] // sometimes ECONNRESET wins the race
2333- async fn http2_service_poll_ready_error_sends_goaway ( ) {
2334- use std:: error:: Error ;
2335-
2336- let _ = pretty_env_logger:: try_init ( ) ;
2337-
2338- let listener = TkTcpListener :: bind ( SocketAddr :: from ( ( [ 127 , 0 , 0 , 1 ] , 0 ) ) )
2339- . await
2340- . unwrap ( ) ;
2341-
2342- let addr_str = format ! ( "http://{}" , listener. local_addr( ) . unwrap( ) ) ;
2343-
2344- tokio:: task:: spawn ( async move {
2345- loop {
2346- tokio:: select! {
2347- res = listener. accept( ) => {
2348- let ( stream, _) = res. unwrap( ) ;
2349-
2350- tokio:: task:: spawn( async move {
2351- let mut http = Http :: new( ) ;
2352- http. http2_only( true ) ;
2353-
2354- let service = Http2ReadyErrorSvc ;
2355- http. serve_connection( stream, service) . await . unwrap( ) ;
2356- } ) ;
2357- }
2358- }
2359- }
2360- } ) ;
2361-
2362- let uri = addr_str. parse ( ) . expect ( "server addr should parse" ) ;
2363- let err = dbg ! ( TestClient :: new( )
2364- . http2_only( )
2365- . get( uri)
2366- . await
2367- . expect_err( "client.get should fail" ) ) ;
2368-
2369- // client request should have gotten the specific GOAWAY error...
2370- let h2_err = err
2371- . source ( )
2372- . expect ( "source" )
2373- . downcast_ref :: < h2:: Error > ( )
2374- . expect ( "downcast" ) ;
2375-
2376- assert_eq ! ( h2_err. reason( ) , Some ( h2:: Reason :: INADEQUATE_SECURITY ) ) ;
2377- }
2378-
23792308#[ test]
23802309fn skips_content_length_for_304_responses ( ) {
23812310 let server = serve ( ) ;
@@ -2781,15 +2710,11 @@ enum Msg {
27812710 End ,
27822711}
27832712
2784- impl tower_service :: Service < Request < Body > > for TestService {
2713+ impl Service < Request < Body > > for TestService {
27852714 type Response = Response < ReplyBody > ;
27862715 type Error = BoxError ;
27872716 type Future = BoxFuture ;
27882717
2789- fn poll_ready ( & mut self , _cx : & mut Context < ' _ > ) -> Poll < Result < ( ) , Self :: Error > > {
2790- Ok ( ( ) ) . into ( )
2791- }
2792-
27932718 fn call ( & mut self , mut req : Request < Body > ) -> Self :: Future {
27942719 let tx = self . tx . clone ( ) ;
27952720 let replies = self . reply . clone ( ) ;
@@ -2848,27 +2773,20 @@ const HELLO: &str = "hello";
28482773
28492774struct HelloWorld ;
28502775
2851- impl tower_service :: Service < Request < Body > > for HelloWorld {
2776+ impl Service < Request < Body > > for HelloWorld {
28522777 type Response = Response < Body > ;
28532778 type Error = hyper:: Error ;
28542779 type Future = future:: Ready < Result < Response < Body > , Self :: Error > > ;
28552780
2856- fn poll_ready ( & mut self , _cx : & mut Context < ' _ > ) -> Poll < Result < ( ) , Self :: Error > > {
2857- Ok ( ( ) ) . into ( )
2858- }
2859-
28602781 fn call ( & mut self , _req : Request < Body > ) -> Self :: Future {
28612782 let response = Response :: new ( HELLO . into ( ) ) ;
28622783 future:: ok ( response)
28632784 }
28642785}
28652786
2866- fn unreachable_service ( ) -> impl tower_service:: Service <
2867- http:: Request < hyper:: Body > ,
2868- Response = http:: Response < ReplyBody > ,
2869- Error = BoxError ,
2870- Future = BoxFuture ,
2871- > {
2787+ fn unreachable_service (
2788+ ) -> impl Service < Request < Body > , Response = Response < ReplyBody > , Error = BoxError , Future = BoxFuture >
2789+ {
28722790 service_fn ( |_req| Box :: pin ( async { Err ( "request shouldn't be received" . into ( ) ) } ) as BoxFuture )
28732791}
28742792
0 commit comments