Skip to content
This repository has been archived by the owner on Jan 15, 2021. It is now read-only.

Commit

Permalink
Merge pull request #825 from Glimpse/502-async-issues-with-preSendReq…
Browse files Browse the repository at this point in the history
…uestHeaders

Support For AspNetSynchronizationContext
  • Loading branch information
nikmd23 committed Jul 17, 2014
2 parents 93256e0 + dd11a2e commit c61c88c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 29 deletions.
15 changes: 6 additions & 9 deletions source/Glimpse.AspNet/AspNetFrameworkProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,13 @@ private static HttpContextBase TryGetOrCaptureLogicalContext()

public void SetHttpResponseHeader(string name, string value)
{
if (!Context.HeadersSent())
try
{
try
{
Context.Response.AppendHeader(name, value);
}
catch (Exception exception)
{
Logger.Error("Exception setting Http response header '{0}' with value '{1}'.", exception, name, value);
}
Context.Response.AppendHeader(name, value);
}
catch (Exception exception)
{
Logger.Error("Exception setting Http response header '{0}' with value '{1}'.", exception, name, value);
}
}

Expand Down
14 changes: 0 additions & 14 deletions source/Glimpse.AspNet/Extensions/HttpContextExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ namespace Glimpse.AspNet.Extensions
{
public static class HttpContextExtensions
{
private const string HeadersSentKey = "__GlimpseHttpHeadersSent";

public static string GenerateGlimpseScriptTags(this HttpContextBase context)
{
var generateScripts = context.Items["__GlimpseClientScriptsStrategy"] as Func<Guid?, string>;
Expand All @@ -18,17 +16,5 @@ public static string GenerateGlimpseScriptTags(this HttpContextBase context)

return generateScripts(null); // null means to use the current request id
}

internal static void HeadersSent(this HttpContextBase context, bool value)
{
context.Items[HeadersSentKey] = value;
}

internal static bool HeadersSent(this HttpContextBase context)
{
var result = context.Items[HeadersSentKey] as bool?;

return result.HasValue ? result.Value : false;
}
}
}
6 changes: 0 additions & 6 deletions source/Glimpse.AspNet/HttpModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ internal void Init(HttpApplicationBase httpApplication)
httpApplication.PostAcquireRequestState += (context, e) => BeginSessionAccess(WithTestable(context));
httpApplication.PostRequestHandlerExecute += (context, e) => EndSessionAccess(WithTestable(context));
httpApplication.PostReleaseRequestState += (context, e) => EndRequest(WithTestable(context));
httpApplication.PreSendRequestHeaders += (context, e) => SendHeaders(WithTestable(context));
}
}

Expand Down Expand Up @@ -115,11 +114,6 @@ internal void EndRequest(HttpContextBase httpContext)
runtime.EndRequest();
}

internal void SendHeaders(HttpContextBase httpContext)
{
httpContext.HeadersSent(true);
}

private static HttpContextBase WithTestable(object sender)
{
var httpApplication = sender as HttpApplication;
Expand Down

0 comments on commit c61c88c

Please sign in to comment.