diff --git a/src/libraries/Common/tests/System/Net/Http/GenericLoopbackServer.cs b/src/libraries/Common/tests/System/Net/Http/GenericLoopbackServer.cs index 67166cfeb0cb0..9a523ca701417 100644 --- a/src/libraries/Common/tests/System/Net/Http/GenericLoopbackServer.cs +++ b/src/libraries/Common/tests/System/Net/Http/GenericLoopbackServer.cs @@ -124,24 +124,24 @@ public abstract class GenericLoopbackConnection : IDisposable /// Sends Response back with provided statusCode, headers and content. /// If isFinal is false, the body is not completed and you can call SendResponseBodyAsync to send more. - public abstract Task SendResponseAsync(HttpStatusCode statusCode = HttpStatusCode.OK, IList headers = null, string content = "", bool isFinal = true, int requestId = 0); + public abstract Task SendResponseAsync(HttpStatusCode statusCode = HttpStatusCode.OK, IList headers = null, string content = "", bool isFinal = true); /// Sends response headers. - public abstract Task SendResponseHeadersAsync(HttpStatusCode statusCode = HttpStatusCode.OK, IList headers = null, int requestId = 0); + public abstract Task SendResponseHeadersAsync(HttpStatusCode statusCode = HttpStatusCode.OK, IList headers = null); /// Sends valid but incomplete headers. Once called, there is no way to continue the response past this point. - public abstract Task SendPartialResponseHeadersAsync(HttpStatusCode statusCode = HttpStatusCode.OK, IList headers = null, int requestId = 0); + public abstract Task SendPartialResponseHeadersAsync(HttpStatusCode statusCode = HttpStatusCode.OK, IList headers = null); /// Sends Response body after SendResponse was called with isFinal: false. - public abstract Task SendResponseBodyAsync(byte[] content, bool isFinal = true, int requestId = 0); + public abstract Task SendResponseBodyAsync(byte[] content, bool isFinal = true); /// Reads Request, sends Response and closes connection. public abstract Task HandleRequestAsync(HttpStatusCode statusCode = HttpStatusCode.OK, IList headers = null, string content = ""); /// Waits for the client to signal cancellation. - public abstract Task WaitForCancellationAsync(bool ignoreIncomingData = true, int requestId = 0); + public abstract Task WaitForCancellationAsync(bool ignoreIncomingData = true); /// Helper function to make it easier to convert old test with strings. - public async Task SendResponseBodyAsync(string content, bool isFinal = true, int requestId = 0) + public async Task SendResponseBodyAsync(string content, bool isFinal = true) { - await SendResponseBodyAsync(String.IsNullOrEmpty(content) ? new byte[0] : Encoding.ASCII.GetBytes(content), isFinal, requestId); + await SendResponseBodyAsync(String.IsNullOrEmpty(content) ? new byte[0] : Encoding.ASCII.GetBytes(content), isFinal); } } diff --git a/src/libraries/Common/tests/System/Net/Http/Http2LoopbackConnection.cs b/src/libraries/Common/tests/System/Net/Http/Http2LoopbackConnection.cs index 18edaca7a6524..b09232bb009e8 100644 --- a/src/libraries/Common/tests/System/Net/Http/Http2LoopbackConnection.cs +++ b/src/libraries/Common/tests/System/Net/Http/Http2LoopbackConnection.cs @@ -864,7 +864,7 @@ public override Task ReadRequestBodyAsync() return ReadBodyAsync(); } - public override async Task SendResponseAsync(HttpStatusCode statusCode = HttpStatusCode.OK, IList headers = null, string content = "", bool isFinal = true, int requestId = 0) + public async Task SendResponseAsync(HttpStatusCode statusCode = HttpStatusCode.OK, IList headers = null, string content = "", bool isFinal = true, int requestId = 0) { if (headers != null) { @@ -910,25 +910,30 @@ public override async Task SendResponseAsync(HttpStatusCode statusCode = HttpSta else { await SendResponseHeadersAsync(streamId, endStream: false, (HttpStatusCode)statusCode, endHeaders: true, headers: headers); - await SendResponseBodyAsync(content, isFinal: isFinal, requestId: streamId); + await SendResponseBodyAsync(content, isFinal: isFinal); } } - public override Task SendResponseHeadersAsync(HttpStatusCode statusCode = HttpStatusCode.OK, IList headers = null, int requestId = 0) + public override Task SendResponseAsync(HttpStatusCode statusCode = HttpStatusCode.OK, IList headers = null, string content = "", bool isFinal = true) { - int streamId = requestId == 0 ? _lastStreamId : requestId; + return SendResponseAsync(statusCode, headers, content, isFinal, requestId: 0); + } + + public override Task SendResponseHeadersAsync(HttpStatusCode statusCode = HttpStatusCode.OK, IList headers = null) + { + int streamId = _lastStreamId; return SendResponseHeadersAsync(streamId, endStream: false, statusCode, isTrailingHeader: false, endHeaders: true, headers); } - public override Task SendPartialResponseHeadersAsync(HttpStatusCode statusCode = HttpStatusCode.OK, IList headers = null, int requestId = 0) + public override Task SendPartialResponseHeadersAsync(HttpStatusCode statusCode = HttpStatusCode.OK, IList headers = null) { - int streamId = requestId == 0 ? _lastStreamId : requestId; + int streamId = _lastStreamId; return SendResponseHeadersAsync(streamId, endStream: false, statusCode, isTrailingHeader: false, endHeaders: false, headers); } - public override Task SendResponseBodyAsync(byte[] content, bool isFinal = true, int requestId = 0) + public override Task SendResponseBodyAsync(byte[] content, bool isFinal = true) { - int streamId = requestId == 0 ? _lastStreamId : requestId; + int streamId = _lastStreamId; return SendResponseBodyAsync(streamId, content, isFinal); } @@ -955,9 +960,9 @@ public override async Task HandleRequestAsync(HttpStatusCode st return requestData; } - public override async Task WaitForCancellationAsync(bool ignoreIncomingData = true, int requestId = 0) + public override async Task WaitForCancellationAsync(bool ignoreIncomingData = true) { - int streamId = requestId == 0 ? _lastStreamId : requestId; + int streamId = _lastStreamId; Frame frame; do diff --git a/src/libraries/Common/tests/System/Net/Http/Http3LoopbackConnection.cs b/src/libraries/Common/tests/System/Net/Http/Http3LoopbackConnection.cs index cb65b22dd0270..ceb36e0bcbfb1 100644 --- a/src/libraries/Common/tests/System/Net/Http/Http3LoopbackConnection.cs +++ b/src/libraries/Common/tests/System/Net/Http/Http3LoopbackConnection.cs @@ -200,24 +200,24 @@ public override async Task ReadRequestDataAsync(bool readBody = return await stream.ReadRequestDataAsync(readBody).ConfigureAwait(false); } - public override Task SendResponseAsync(HttpStatusCode statusCode = HttpStatusCode.OK, IList headers = null, string content = "", bool isFinal = true, int requestId = 0) + public override Task SendResponseAsync(HttpStatusCode statusCode = HttpStatusCode.OK, IList headers = null, string content = "", bool isFinal = true) { - return GetOpenRequest(requestId).SendResponseAsync(statusCode, headers, content, isFinal); + return GetOpenRequest().SendResponseAsync(statusCode, headers, content, isFinal); } - public override Task SendResponseBodyAsync(byte[] content, bool isFinal = true, int requestId = 0) + public override Task SendResponseBodyAsync(byte[] content, bool isFinal = true) { - return GetOpenRequest(requestId).SendResponseBodyAsync(content, isFinal); + return GetOpenRequest().SendResponseBodyAsync(content, isFinal); } - public override Task SendResponseHeadersAsync(HttpStatusCode statusCode = HttpStatusCode.OK, IList headers = null, int requestId = 0) + public override Task SendResponseHeadersAsync(HttpStatusCode statusCode = HttpStatusCode.OK, IList headers = null) { - return GetOpenRequest(requestId).SendResponseHeadersAsync(statusCode, headers); + return GetOpenRequest().SendResponseHeadersAsync(statusCode, headers); } - public override Task SendPartialResponseHeadersAsync(HttpStatusCode statusCode = HttpStatusCode.OK, IList headers = null, int requestId = 0) + public override Task SendPartialResponseHeadersAsync(HttpStatusCode statusCode = HttpStatusCode.OK, IList headers = null) { - return GetOpenRequest(requestId).SendPartialResponseHeadersAsync(statusCode, headers); + return GetOpenRequest().SendPartialResponseHeadersAsync(statusCode, headers); } public override async Task HandleRequestAsync(HttpStatusCode statusCode = HttpStatusCode.OK, IList headers = null, string content = "") @@ -301,9 +301,9 @@ public async Task WaitForClientDisconnectAsync(bool refuseNewRequests = true) await CloseAsync(H3_NO_ERROR); } - public override async Task WaitForCancellationAsync(bool ignoreIncomingData = true, int requestId = 0) + public override async Task WaitForCancellationAsync(bool ignoreIncomingData = true) { - await GetOpenRequest(requestId).WaitForCancellationAsync(ignoreIncomingData).ConfigureAwait(false); + await GetOpenRequest().WaitForCancellationAsync(ignoreIncomingData).ConfigureAwait(false); } } diff --git a/src/libraries/Common/tests/System/Net/Http/LoopbackServer.cs b/src/libraries/Common/tests/System/Net/Http/LoopbackServer.cs index ff4b34630525b..30cb5d4a3f043 100644 --- a/src/libraries/Common/tests/System/Net/Http/LoopbackServer.cs +++ b/src/libraries/Common/tests/System/Net/Http/LoopbackServer.cs @@ -872,7 +872,7 @@ public void CompleteRequestProcessing() _bodyRead = false; } - public override async Task SendResponseAsync(HttpStatusCode statusCode = HttpStatusCode.OK, IList headers = null, string content = "", bool isFinal = true, int requestId = 0) + public override async Task SendResponseAsync(HttpStatusCode statusCode = HttpStatusCode.OK, IList headers = null, string content = "", bool isFinal = true) { MemoryStream headerBytes = new MemoryStream(); int contentLength = -1; @@ -933,7 +933,7 @@ public override async Task SendResponseAsync(HttpStatusCode statusCode = HttpSta if (content != null) { - await SendResponseBodyAsync(content, isFinal: isFinal, requestId: requestId).ConfigureAwait(false); + await SendResponseBodyAsync(content, isFinal: isFinal).ConfigureAwait(false); } } @@ -955,13 +955,13 @@ private string GetResponseHeaderString(HttpStatusCode statusCode, IList headers = null, int requestId = 0) + public override async Task SendResponseHeadersAsync(HttpStatusCode statusCode = HttpStatusCode.OK, IList headers = null) { string headerString = GetResponseHeaderString(statusCode, headers); await SendResponseAsync(headerString).ConfigureAwait(false); } - public override async Task SendPartialResponseHeadersAsync(HttpStatusCode statusCode = HttpStatusCode.OK, IList headers = null, int requestId = 0) + public override async Task SendPartialResponseHeadersAsync(HttpStatusCode statusCode = HttpStatusCode.OK, IList headers = null) { string headerString = GetResponseHeaderString(statusCode, headers); @@ -971,7 +971,7 @@ public override async Task SendPartialResponseHeadersAsync(HttpStatusCode status await SendResponseAsync(headerString).ConfigureAwait(false); } - public override async Task SendResponseBodyAsync(byte[] content, bool isFinal = true, int requestId = 0) + public override async Task SendResponseBodyAsync(byte[] content, bool isFinal = true) { await SendResponseAsync(content).ConfigureAwait(false); } @@ -1047,7 +1047,7 @@ public override async Task HandleRequestAsync(HttpStatusCode st return requestData; } - public override async Task WaitForCancellationAsync(bool ignoreIncomingData = true, int requestId = 0) + public override async Task WaitForCancellationAsync(bool ignoreIncomingData = true) { var buffer = new byte[1024]; while (true)