@@ -3525,7 +3525,7 @@ public async Task RequestTimeoutDisabledWhenConnected(HttpTransportType transpor
35253525 app . UseRouting ( ) ;
35263526 app . UseEndpoints ( endpoints =>
35273527 {
3528- endpoints . MapConnectionHandler < TestConnectionHandler > ( "/foo" ) ;
3528+ endpoints . MapConnectionHandler < EchoConnectionHandler > ( "/foo" ) ;
35293529 } ) ;
35303530 } )
35313531 . UseUrls ( "http://127.0.0.1:0" ) ;
@@ -3550,6 +3550,10 @@ public async Task RequestTimeoutDisabledWhenConnected(HttpTransportType transpor
35503550
35513551 await connection . StartAsync ( ) ;
35523552
3553+ // Easy way to make sure everything is set is to send and receive data over the connection
3554+ await connection . Transport . Output . WriteAsync ( new byte [ 2 ] ) ;
3555+ await connection . Transport . Input . ReadAsync ( ) ;
3556+
35533557 var negotiateResponse = NegotiateProtocol . ParseResponse ( stream . ToArray ( ) ) ;
35543558
35553559 Assert . True ( manager . TryGetConnection ( negotiateResponse . ConnectionToken , out var context ) ) ;
@@ -3898,6 +3902,34 @@ public override async Task OnConnectedAsync(ConnectionContext connection)
38983902 }
38993903}
39003904
3905+ public class EchoConnectionHandler : ConnectionHandler
3906+ {
3907+ public override async Task OnConnectedAsync ( ConnectionContext connection )
3908+ {
3909+ while ( true )
3910+ {
3911+ var result = await connection . Transport . Input . ReadAsync ( ) ;
3912+ var buffer = result . Buffer ;
3913+
3914+ try
3915+ {
3916+ if ( ! buffer . IsEmpty )
3917+ {
3918+ await connection . Transport . Output . WriteAsync ( buffer . ToArray ( ) ) ;
3919+ }
3920+ else if ( result . IsCompleted )
3921+ {
3922+ break ;
3923+ }
3924+ }
3925+ finally
3926+ {
3927+ connection . Transport . Input . AdvanceTo ( result . Buffer . End ) ;
3928+ }
3929+ }
3930+ }
3931+ }
3932+
39013933public class ServiceProviderConnectionHandler : ConnectionHandler
39023934{
39033935 public override async Task OnConnectedAsync ( ConnectionContext connection )
0 commit comments