diff --git a/src/libraries/System.Net.Http/tests/FunctionalTests/SocketsHttpHandlerTest.cs b/src/libraries/System.Net.Http/tests/FunctionalTests/SocketsHttpHandlerTest.cs index b58fc6bc788c7..7c40a33bffaeb 100644 --- a/src/libraries/System.Net.Http/tests/FunctionalTests/SocketsHttpHandlerTest.cs +++ b/src/libraries/System.Net.Http/tests/FunctionalTests/SocketsHttpHandlerTest.cs @@ -2237,23 +2237,24 @@ private static async Task GetConnection(Http2LoopbackSe private async Task<(int Count, int LastStreamId)> HandleAllPendingRequests(Http2LoopbackConnection connection, int totalRequestCount) { - int streamId = -1; + int lastStreamId = -1; for (int i = 0; i < totalRequestCount; i++) { try { // Exact number of requests sent over the given connection is unknown, // so we keep reading headers and sending response while there are available requests. - streamId = await connection.ReadRequestHeaderAsync().ConfigureAwait(false); + (int streamId, _) = await connection.ReadAndParseRequestHeaderAsync().ConfigureAwait(false); await connection.SendDefaultResponseAsync(streamId).ConfigureAwait(false); + lastStreamId = streamId; } catch (OperationCanceledException) { - return (i, streamId); + return (i, lastStreamId); } } - return (totalRequestCount, streamId); + return (totalRequestCount, lastStreamId); } private async Task> AcceptRequests(Http2LoopbackConnection connection, int maxRequests = int.MaxValue) @@ -2263,7 +2264,8 @@ private async Task> AcceptRequests(Http2LoopbackConnection connection, { try { - streamIds.Add(await connection.ReadRequestHeaderAsync().ConfigureAwait(false)); + (int streamId, _) = await connection.ReadAndParseRequestHeaderAsync().ConfigureAwait(false); + streamIds.Add(streamId); } catch (OperationCanceledException) {