Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
WIP
  • Loading branch information
scalablecory committed Jun 22, 2021
commit d100b6fd1121c4e713f949c0a9e16e33b18158df
17 changes: 7 additions & 10 deletions src/libraries/Common/tests/System/Net/Http/Http3LoopbackStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
namespace System.Net.Test.Common
{

internal sealed class Http3LoopbackStream : IDisposable
internal sealed class Http3LoopbackStream : IDisposable, IAsyncDisposable
{
private const int MaximumVarIntBytes = 8;
private const long VarIntMax = (1L << 62) - 1;
Expand Down Expand Up @@ -43,6 +43,10 @@ public void Dispose()
{
_stream.Dispose();
}

public ValueTask DisposeAsync() =>
_stream.DisposeAsync();

public async Task<HttpRequestData> HandleRequestAsync(HttpStatusCode statusCode = HttpStatusCode.OK, IList<HttpHeaderData> headers = null, string content = "")
{
HttpRequestData request = await ReadRequestDataAsync().ConfigureAwait(false);
Expand Down Expand Up @@ -116,12 +120,6 @@ public async Task SendFrameAsync(long frameType, ReadOnlyMemory<byte> framePaylo
await _stream.WriteAsync(framePayload).ConfigureAwait(false);
}

public async Task ShutdownSendAsync()
{
await _stream.CompleteWritesAsync().ConfigureAwait(false);
await _stream.ShutdownWriteCompleted().ConfigureAwait(false);
}

static int EncodeHttpInteger(long longToEncode, Span<byte> buffer)
{
Debug.Assert(longToEncode >= 0);
Expand Down Expand Up @@ -226,9 +224,8 @@ public async Task SendResponseBodyAsync(byte[] content, bool isFinal = true)

if (isFinal)
{
await ShutdownSendAsync().ConfigureAwait(false);
await _stream.ShutdownCompleted().ConfigureAwait(false);
Dispose();
_stream.CompleteWrites();
await DisposeAsync();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,6 @@ await RunClientServer(
break;
}
}

stream.CompleteWrites();
},
async serverConnection =>
{
Expand All @@ -247,8 +245,6 @@ await RunClientServer(

int expectedTotalBytes = writes.SelectMany(x => x).Sum();
Assert.Equal(expectedTotalBytes, totalBytes);

stream.CompleteWrites();
});
}

Expand Down