Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3525,7 +3525,7 @@ public async Task RequestTimeoutDisabledWhenConnected(HttpTransportType transpor
app.UseRouting();
app.UseEndpoints(endpoints =>
{
endpoints.MapConnectionHandler<TestConnectionHandler>("/foo");
endpoints.MapConnectionHandler<EchoConnectionHandler>("/foo");
});
})
.UseUrls("http://127.0.0.1:0");
Expand All @@ -3550,6 +3550,10 @@ public async Task RequestTimeoutDisabledWhenConnected(HttpTransportType transpor

await connection.StartAsync();

// Easy way to make sure everything is set is to send and receive data over the connection
await connection.Transport.Output.WriteAsync(new byte[2]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are two bytes necessary for this or is any number of bytes sufficient?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any number, not sure why I put 2 😆

await connection.Transport.Input.ReadAsync();

var negotiateResponse = NegotiateProtocol.ParseResponse(stream.ToArray());

Assert.True(manager.TryGetConnection(negotiateResponse.ConnectionToken, out var context));
Expand Down Expand Up @@ -3898,6 +3902,34 @@ public override async Task OnConnectedAsync(ConnectionContext connection)
}
}

public class EchoConnectionHandler : ConnectionHandler
{
public override async Task OnConnectedAsync(ConnectionContext connection)
{
while (true)
{
var result = await connection.Transport.Input.ReadAsync();
var buffer = result.Buffer;

try
{
if (!buffer.IsEmpty)
{
await connection.Transport.Output.WriteAsync(buffer.ToArray());
}
else if (result.IsCompleted)
{
break;
}
}
finally
{
connection.Transport.Input.AdvanceTo(result.Buffer.End);
}
}
}
}

public class ServiceProviderConnectionHandler : ConnectionHandler
{
public override async Task OnConnectedAsync(ConnectionContext connection)
Expand Down
Loading