Skip to content
This repository was archived by the owner on Jul 9, 2023. It is now read-only.

Commit 108c040

Browse files
authored
Merge pull request #660 from justcoding121/master
fix for #652
2 parents 6923f8a + 21f8190 commit 108c040

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

src/Titanium.Web.Proxy/EventArguments/SessionEventArgs.cs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ namespace Titanium.Web.Proxy.EventArguments
2222
/// </summary>
2323
public class SessionEventArgs : SessionEventArgsBase
2424
{
25-
private static readonly byte[] emptyData = new byte[0];
26-
2725
/// <summary>
2826
/// Backing field for corresponding public property
2927
/// </summary>
@@ -110,7 +108,10 @@ private async Task readRequestBodyAsync(CancellationToken cancellationToken)
110108
else
111109
{
112110
var body = await readBodyAsync(true, cancellationToken);
113-
request.Body = body;
111+
if (!request.BodyAvailable)
112+
{
113+
request.Body = body;
114+
}
114115

115116
// Now set the flag to true
116117
// So that next time we can deliver body from cache
@@ -182,7 +183,10 @@ private async Task readResponseBodyAsync(CancellationToken cancellationToken)
182183
else
183184
{
184185
var body = await readBodyAsync(false, cancellationToken);
185-
response.Body = body;
186+
if (!response.BodyAvailable)
187+
{
188+
response.Body = body;
189+
}
186190

187191
// Now set the flag to true
188192
// So that next time we can deliver body from cache
@@ -595,7 +599,7 @@ public void Redirect(string url, bool closeServerConnection = false)
595599
var response = new RedirectResponse();
596600
response.HttpVersion = HttpClient.Request.HttpVersion;
597601
response.Headers.AddHeader(KnownHeaders.Location, url);
598-
response.Body = emptyData;
602+
response.Body = Array.Empty<byte>();
599603

600604
Respond(response, closeServerConnection);
601605
}

src/Titanium.Web.Proxy/Http2/Http2Helper.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,10 @@ private static async Task copyHttp2FrameAsync(Stream input, Stream output,
389389
}
390390
}
391391

392-
rr.Body = body;
392+
if (!rr.BodyAvailable)
393+
{
394+
rr.Body = body;
395+
}
393396
}
394397

395398
rr.IsBodyRead = true;

0 commit comments

Comments
 (0)