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

Commit ef38da7

Browse files
committed
allow to set custom response body on redirect
1 parent 9c3a4f2 commit ef38da7

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

Titanium.Web.Proxy/Http/RequestResponseBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ internal byte[] GetCompressedBody(string encodingType, byte[] body)
173173

174174
internal byte[] CompressBodyAndUpdateContentLength()
175175
{
176-
if (!IsBodyRead)
176+
if (!IsBodyRead && BodyInternal == null)
177177
{
178178
return null;
179179
}

Titanium.Web.Proxy/Http/Response.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,21 @@ public override string HeaderText
128128
}
129129
}
130130

131+
/// <summary>
132+
/// Constructor.
133+
/// </summary>
134+
public Response()
135+
{
136+
}
137+
138+
/// <summary>
139+
/// Constructor.
140+
/// </summary>
141+
public Response(byte[] body)
142+
{
143+
Body = body;
144+
}
145+
131146
internal static string CreateResponseLine(Version version, int statusCode, string statusDescription)
132147
{
133148
return $"HTTP/{version.Major}.{version.Minor} {statusCode} {statusDescription}";

Titanium.Web.Proxy/Http/Responses/OkResponse.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,13 @@ public OkResponse()
1515
StatusCode = (int)HttpStatusCode.OK;
1616
StatusDescription = "OK";
1717
}
18+
19+
/// <summary>
20+
/// Constructor.
21+
/// </summary>
22+
public OkResponse(byte[] body) : this()
23+
{
24+
Body = body;
25+
}
1826
}
1927
}

0 commit comments

Comments
 (0)