Skip to content

Commit

Permalink
Fixes response handling
Browse files Browse the repository at this point in the history
The callbacks for directing the next action are mangled in such a way that:

Requesting response inspection will never result in a response inspection callback.
Request headers are sent to the callbacks for the response messages.
We completely ignore the proxy next action directive on responses.

All issues fixed here.

Fixes #11
  • Loading branch information
TechnikEmpire committed Nov 10, 2017
1 parent 1343dfd commit 8afd420
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions CitadelCore/CitadelCore/CitadelCore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
<PackageIconUrl />
<RepositoryUrl>https://github.com/TechnikEmpire/CitadelCore</RepositoryUrl>
<PackageTags>proxy filtering content-filtering transparent-proxy</PackageTags>
<PackageReleaseNotes>Fixes several issues. See github release for more details.</PackageReleaseNotes>
<PackageReleaseNotes>Fixes issues with classification and next action directives regarding http responses.</PackageReleaseNotes>
<Description>Transparent filtering HTTP/S and Websocket/WebsocketSecure proxy.</Description>
<Version>1.2.12</Version>
<AssemblyVersion>1.2.12.0</AssemblyVersion>
<FileVersion>1.2.12.0</FileVersion>
<Version>1.2.13</Version>
<AssemblyVersion>1.2.13.0</AssemblyVersion>
<FileVersion>1.2.13.0</FileVersion>
</PropertyGroup>

<ItemGroup Label="dotnet pack instructions">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,9 +300,9 @@ public override async Task Handle(HttpContext context)
string responseBlockResponseContentType = string.Empty;
byte[] responseBlockResponse = null;

m_msgBeginCb?.Invoke(reqUrl, resHeaderBuilder.ToString(), m_nullBody, context.Request.IsHttps ? MessageType.Https : MessageType.Http, MessageDirection.Request, out responseNextAction, out responseBlockResponseContentType, out responseBlockResponse);
m_msgBeginCb?.Invoke(reqUrl, resHeaderBuilder.ToString(), m_nullBody, context.Request.IsHttps ? MessageType.Https : MessageType.Http, MessageDirection.Response, out responseNextAction, out responseBlockResponseContentType, out responseBlockResponse);

if(requestNextAction == ProxyNextAction.DropConnection)
if(responseNextAction == ProxyNextAction.DropConnection)
{
if(responseBlockResponse != null)
{
Expand All @@ -318,7 +318,7 @@ public override async Task Handle(HttpContext context)
}
}

if(requestNextAction == ProxyNextAction.AllowButRequestContentInspection)
if(responseNextAction == ProxyNextAction.AllowButRequestContentInspection)
{
using(var upstreamResponseStream = await response.Content.ReadAsStreamAsync())
{
Expand All @@ -337,7 +337,7 @@ public override async Task Handle(HttpContext context)
bool shouldBlockResponse = false;
responseBlockResponseContentType = string.Empty;
responseBlockResponse = null;
m_msgEndCb?.Invoke(reqUrl, reqHeaderBuilder.ToString(), responseBody, context.Request.IsHttps ? MessageType.Https : MessageType.Http, MessageDirection.Request, out shouldBlockResponse, out responseBlockResponseContentType, out responseBlockResponse);
m_msgEndCb?.Invoke(reqUrl, resHeaderBuilder.ToString(), responseBody, context.Request.IsHttps ? MessageType.Https : MessageType.Http, MessageDirection.Response, out shouldBlockResponse, out responseBlockResponseContentType, out responseBlockResponse);

if(shouldBlockResponse)
{
Expand Down

0 comments on commit 8afd420

Please sign in to comment.