diff --git a/tools/test-proxy/Azure.Sdk.Tools.TestProxy/RecordingHandler.cs b/tools/test-proxy/Azure.Sdk.Tools.TestProxy/RecordingHandler.cs index bfe27e65823..966e3c21cb7 100644 --- a/tools/test-proxy/Azure.Sdk.Tools.TestProxy/RecordingHandler.cs +++ b/tools/test-proxy/Azure.Sdk.Tools.TestProxy/RecordingHandler.cs @@ -488,8 +488,9 @@ public byte[][] GetBatches(byte[] bodyData, int batchCount) for(int i = 0; i < batches.Length; i++) { - var batch = new byte[chunkLength]; - Array.Copy(bodyData, i * chunkLength, batch, 0, i == batches.Length - 1 && batches.Length > 1 && remainder > 0 ? remainder : chunkLength); + var calculatedChunkLength = i == batches.Length - 1 && batches.Length > 1 && remainder > 0 ? remainder : chunkLength; + var batch = new byte[calculatedChunkLength]; + Array.Copy(bodyData, i * chunkLength, batch, 0, calculatedChunkLength); batches[i] = batch; } @@ -515,6 +516,10 @@ public async Task WriteBodyBytes(byte[] bodyData, int playbackResponseTime, Http { Thread.Sleep(sleepLength); } + else + { + await outgoingResponse.Body.FlushAsync().ConfigureAwait(false); + } } } else