@@ -605,6 +605,56 @@ async fn f() -> Result<(), BoxError> {
605605 Ok ( ( ) )
606606}
607607
608+ #[ it( "should reject n = 0" ) ]
609+ async fn f ( ) -> Result < ( ) , BoxError > {
610+ let serve: Serve = serve ( ) . await ;
611+
612+ {
613+ let send_body_str = "this is a content" ;
614+ let send_req = hyper:: Request :: builder ( )
615+ . method ( hyper:: Method :: POST )
616+ . header ( "Content-Type" , "text/plain" )
617+ . uri ( format ! ( "http://{}/mypath?n=0" , serve. addr) )
618+ . body ( hyper:: Body :: from ( send_body_str) ) ?;
619+
620+ let client = Client :: new ( ) ;
621+ let send_res = client. request ( send_req) . await ?;
622+ let ( send_res_parts, _send_res_body) = send_res. into_parts ( ) ;
623+ assert_eq ! ( send_res_parts. status, http:: StatusCode :: BAD_REQUEST ) ;
624+ assert_eq ! (
625+ get_header_value( & send_res_parts. headers, "content-type" ) ,
626+ Some ( "text/plain" )
627+ ) ;
628+ assert_eq ! (
629+ get_header_value( & send_res_parts. headers, "access-control-allow-origin" ) ,
630+ Some ( "*" )
631+ ) ;
632+ }
633+
634+ {
635+ let get_req = hyper:: Request :: builder ( )
636+ . method ( hyper:: Method :: GET )
637+ . uri ( format ! ( "http://{}/mypath?n=0" , serve. addr) )
638+ . body ( hyper:: Body :: empty ( ) ) ?;
639+
640+ let client = Client :: new ( ) ;
641+ let get_res = client. request ( get_req) . await ?;
642+ let ( get_res_parts, _get_res_body) = get_res. into_parts ( ) ;
643+ assert_eq ! ( get_res_parts. status, http:: StatusCode :: BAD_REQUEST ) ;
644+ assert_eq ! (
645+ get_header_value( & get_res_parts. headers, "content-type" ) ,
646+ Some ( "text/plain" )
647+ ) ;
648+ assert_eq ! (
649+ get_header_value( & get_res_parts. headers, "access-control-allow-origin" ) ,
650+ Some ( "*" )
651+ ) ;
652+ }
653+
654+ serve. shutdown_tx . send ( ( ) ) . expect ( "shutdown failed" ) ;
655+ Ok ( ( ) )
656+ }
657+
608658#[ it( "should reject n > 1 because not supported yet" ) ]
609659async fn f ( ) -> Result < ( ) , BoxError > {
610660 let serve: Serve = serve ( ) . await ;
0 commit comments