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

fix for #652 #660

Merged
merged 1 commit into from
Nov 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
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
14 changes: 9 additions & 5 deletions src/Titanium.Web.Proxy/EventArguments/SessionEventArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ namespace Titanium.Web.Proxy.EventArguments
/// </summary>
public class SessionEventArgs : SessionEventArgsBase
{
private static readonly byte[] emptyData = new byte[0];

/// <summary>
/// Backing field for corresponding public property
/// </summary>
Expand Down Expand Up @@ -110,7 +108,10 @@ private async Task readRequestBodyAsync(CancellationToken cancellationToken)
else
{
var body = await readBodyAsync(true, cancellationToken);
request.Body = body;
if (!request.BodyAvailable)
{
request.Body = body;
}

// Now set the flag to true
// So that next time we can deliver body from cache
Expand Down Expand Up @@ -182,7 +183,10 @@ private async Task readResponseBodyAsync(CancellationToken cancellationToken)
else
{
var body = await readBodyAsync(false, cancellationToken);
response.Body = body;
if (!response.BodyAvailable)
{
response.Body = body;
}

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

Respond(response, closeServerConnection);
}
Expand Down
5 changes: 4 additions & 1 deletion src/Titanium.Web.Proxy/Http2/Http2Helper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,10 @@ private static async Task copyHttp2FrameAsync(Stream input, Stream output,
}
}

rr.Body = body;
if (!rr.BodyAvailable)
{
rr.Body = body;
}
}

rr.IsBodyRead = true;
Expand Down