@@ -579,6 +579,60 @@ async fn f() -> Result<(), BoxError> {
579579 Ok ( ( ) )
580580}
581581
582+ #[ it( "should reject a sender connecting a path another sender connected already" ) ]
583+ async fn f ( ) -> Result < ( ) , BoxError > {
584+ let serve: Serve = serve ( ) . await ;
585+
586+ let uri = format ! ( "http://{}/mypath" , serve. addr) . parse :: < http:: Uri > ( ) ?;
587+
588+ {
589+ let send_body_str = "this is a content" ;
590+ let send_req = hyper:: Request :: builder ( )
591+ . method ( hyper:: Method :: POST )
592+ . header ( "Content-Type" , "text/plain" )
593+ . uri ( uri. clone ( ) )
594+ . body ( hyper:: Body :: from ( send_body_str) ) ?;
595+
596+ let client = Client :: new ( ) ;
597+ let send_res = client. request ( send_req) . await ?;
598+ let ( send_res_parts, _send_res_body) = send_res. into_parts ( ) ;
599+ assert_eq ! ( send_res_parts. status, http:: StatusCode :: OK ) ;
600+ assert_eq ! (
601+ get_header_value( & send_res_parts. headers, "content-type" ) ,
602+ Some ( "text/plain" )
603+ ) ;
604+ assert_eq ! (
605+ get_header_value( & send_res_parts. headers, "access-control-allow-origin" ) ,
606+ Some ( "*" )
607+ ) ;
608+ }
609+
610+ {
611+ let send_body_str = "this is a content" ;
612+ let send_req = hyper:: Request :: builder ( )
613+ . method ( hyper:: Method :: POST )
614+ . header ( "Content-Type" , "text/plain" )
615+ . uri ( uri. clone ( ) )
616+ . body ( hyper:: Body :: from ( send_body_str) ) ?;
617+
618+ let client = Client :: new ( ) ;
619+ let send_res = client. request ( send_req) . await ?;
620+ let ( send_res_parts, _send_res_body) = send_res. into_parts ( ) ;
621+ assert_eq ! ( send_res_parts. status, http:: StatusCode :: BAD_REQUEST ) ;
622+ assert_eq ! (
623+ get_header_value( & send_res_parts. headers, "content-type" ) ,
624+ Some ( "text/plain" )
625+ ) ;
626+ assert_eq ! (
627+ get_header_value( & send_res_parts. headers, "access-control-allow-origin" ) ,
628+ Some ( "*" )
629+ ) ;
630+ }
631+
632+ serve. shutdown_tx . send ( ( ) ) . expect ( "shutdown failed" ) ;
633+ Ok ( ( ) )
634+ }
635+
582636// TODO: add tests when sender or receiver receive 400
583637
584638#[ it( "should reject invalid n" ) ]
0 commit comments