@@ -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 }
0 commit comments