@@ -509,6 +509,73 @@ async fn pipelining_ok_then_ok() {
509509 . await ;
510510}
511511
512+ #[ actix_rt:: test]
513+ async fn early_response_with_payload_closes_connection ( ) {
514+ lazy ( |cx| {
515+ let buf = TestBuffer :: new (
516+ "\
517+ GET /unfinished HTTP/1.1\r \n \
518+ Content-Length: 2\r \n \
519+ \r \n \
520+ ",
521+ ) ;
522+
523+ let cfg = ServiceConfig :: new (
524+ KeepAlive :: Os ,
525+ Duration :: from_millis ( 1 ) ,
526+ Duration :: from_millis ( 1 ) ,
527+ false ,
528+ None ,
529+ ) ;
530+
531+ let services = HttpFlow :: new ( echo_path_service ( ) , ExpectHandler , None ) ;
532+
533+ let h1 = Dispatcher :: < _ , _ , _ , _ , UpgradeHandler > :: new (
534+ buf. clone ( ) ,
535+ services,
536+ cfg,
537+ None ,
538+ OnConnectData :: default ( ) ,
539+ ) ;
540+
541+ pin ! ( h1) ;
542+
543+ assert ! ( matches!( & h1. inner, DispatcherState :: Normal { .. } ) ) ;
544+
545+ match h1. as_mut ( ) . poll ( cx) {
546+ Poll :: Pending => panic ! ( "Should have shut down" ) ,
547+ Poll :: Ready ( res) => assert ! ( res. is_ok( ) ) ,
548+ }
549+
550+ // polls: initial => shutdown
551+ assert_eq ! ( h1. poll_count, 2 ) ;
552+
553+ {
554+ let mut res = buf. write_buf_slice_mut ( ) ;
555+ stabilize_date_header ( & mut res) ;
556+ let res = & res[ ..] ;
557+
558+ let exp = b"\
559+ HTTP/1.1 200 OK\r \n \
560+ content-length: 11\r \n \
561+ date: Thu, 01 Jan 1970 12:34:56 UTC\r \n \r \n \
562+ /unfinished\
563+ ";
564+
565+ assert_eq ! (
566+ res,
567+ exp,
568+ "\n expected response not in write buffer:\n \
569+ response: {:?}\n \
570+ expected: {:?}",
571+ String :: from_utf8_lossy( res) ,
572+ String :: from_utf8_lossy( exp)
573+ ) ;
574+ }
575+ } )
576+ . await ;
577+ }
578+
512579#[ actix_rt:: test]
513580async fn pipelining_ok_then_bad ( ) {
514581 lazy ( |cx| {
0 commit comments