Commit 42a5ee99 authored by Honfika's avatar Honfika

allow to change http/2 body

parent 7330b5c3
......@@ -159,6 +159,9 @@ namespace Titanium.Web.Proxy.Examples.Wpf
//{
//}
//if (!e.HttpClient.Request.RequestUri.ToString().Contains("/mail/u/"))
// return;
if (e.HttpClient.Request.HasBody)
{
e.HttpClient.Request.KeepBody = true;
......@@ -177,7 +180,10 @@ namespace Titanium.Web.Proxy.Examples.Wpf
}
});
e.HttpClient.Response.Headers.AddHeader("X-Titanium-Header", "HTTP/2 works");
//e.SetResponseBody(Encoding.ASCII.GetBytes("TITANIUMMMM!!!!"));
//if (!e.HttpClient.Request.RequestUri.ToString().Contains("/mail/u/"))
// return;
//e.HttpClient.Response.Headers.AddHeader("X-Titanium-Header", "HTTP/2 works");
//if (e.HttpClient.ConnectRequest?.TunnelType == TunnelType.Http2)
//{
......
......@@ -91,6 +91,9 @@ namespace Titanium.Web.Proxy.EventArguments
{
if (request.HttpVersion == HttpHeader.Version20)
{
// do not send to the remote endpoint
request.Http2IgnoreBodyFrames = true;
request.Http2BodyData = new MemoryStream();
var tcs = new TaskCompletionSource<bool>();
......@@ -100,6 +103,10 @@ namespace Titanium.Web.Proxy.EventArguments
request.ReadHttp2BeforeHandlerTaskCompletionSource.SetResult(true);
await tcs.Task;
// Now set the flag to true
// So that next time we can deliver body from cache
request.IsBodyRead = true;
}
else
{
......@@ -157,6 +164,9 @@ namespace Titanium.Web.Proxy.EventArguments
{
if (response.HttpVersion == HttpHeader.Version20)
{
// do not send to the remote endpoint
response.Http2IgnoreBodyFrames = true;
response.Http2BodyData = new MemoryStream();
var tcs = new TaskCompletionSource<bool>();
......@@ -166,6 +176,10 @@ namespace Titanium.Web.Proxy.EventArguments
response.ReadHttp2BeforeHandlerTaskCompletionSource.SetResult(true);
await tcs.Task;
// Now set the flag to true
// So that next time we can deliver body from cache
response.IsBodyRead = true;
}
else
{
......
......@@ -56,6 +56,15 @@ namespace Titanium.Web.Proxy.Http
internal MemoryStream Http2BodyData;
internal bool Http2IgnoreBodyFrames;
internal Task Http2BeforeHandlerTask;
/// <summary>
/// Priority used only in HTTP/2
/// </summary>
internal long? Priority;
/// <summary>
/// Keeps the body data after the session is finished.
/// </summary>
......@@ -201,6 +210,8 @@ namespace Titanium.Web.Proxy.Http
/// </summary>
internal bool Locked { get; set; }
internal bool BodyAvailable => BodyInternal != null;
internal abstract void EnsureBodyAvailable(bool throwWhenNotReadYet = true);
/// <summary>
......
This diff is collapsed.
......@@ -125,7 +125,6 @@ namespace Titanium.Web.Proxy
}
args.TimeLine["Response Sent"] = DateTime.Now;
}
/// <summary>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment