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

Commit 32fb817

Browse files
committed
set content-length correctly
1 parent 34a6807 commit 32fb817

File tree

4 files changed

+8
-3
lines changed

4 files changed

+8
-3
lines changed

Titanium.Web.Proxy/Http/Request.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ public long ContentLength
7474
header.Value = value.ToString();
7575
else
7676
RequestHeaders.Add(new HttpHeader("content-length", value.ToString()));
77+
78+
IsChunked = false;
7779
}
7880
else
7981
{

Titanium.Web.Proxy/Http/Response.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ internal long ContentLength
9191
header.Value = value.ToString();
9292
else
9393
ResponseHeaders.Add(new HttpHeader("content-length", value.ToString()));
94+
95+
IsChunked = false;
9496
}
9597
else
9698
{

Titanium.Web.Proxy/RequestHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ await TcpConnectionManager.GetClient(args, args.WebSession.Request.RequestUri.Ho
303303
{
304304
args.WebSession.Request.RequestBody = await GetCompressedResponseBody(args.WebSession.Request.ContentEncoding, args.WebSession.Request.RequestBody);
305305
}
306-
306+
//chunked send is not supported as of now
307307
args.WebSession.Request.ContentLength = args.WebSession.Request.RequestBody.Length;
308308

309309
var newStream = args.WebSession.ServerConnection.Stream;

Titanium.Web.Proxy/ResponseHandler.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,10 @@ public static async Task HandleHttpSessionResponse(SessionEventArgs args)
6666
if (contentEncoding != null)
6767
{
6868
args.WebSession.Response.ResponseBody = await GetCompressedResponseBody(contentEncoding, args.WebSession.Response.ResponseBody).ConfigureAwait(false);
69-
}
7069

71-
args.WebSession.Response.ContentLength = args.WebSession.Response.ResponseBody.Length;
70+
if (isChunked==false)
71+
args.WebSession.Response.ContentLength = args.WebSession.Response.ResponseBody.Length;
72+
}
7273

7374
await WriteResponseHeaders(args.Client.ClientStreamWriter, args.WebSession.Response.ResponseHeaders).ConfigureAwait(false);
7475
await WriteResponseBody(args.Client.ClientStream, args.WebSession.Response.ResponseBody, isChunked).ConfigureAwait(false);

0 commit comments

Comments
 (0)