Permalink
Browse files

Be unit test friendly by avoiding NullRefEx errors when AppHost / End…

…pointHost.Config aren't set
  • Loading branch information...
1 parent 296d78f commit 24d5a370a98d50cee87b84462edf3c408d94c76c @mythz mythz committed Aug 28, 2012
@@ -332,7 +332,10 @@ internal static void CompleteRequest()
{
try
{
- AppHost.OnEndRequest();
+ if (AppHost != null)
+ {
+ AppHost.OnEndRequest();
+ }
}
catch (Exception ex) {}
}
@@ -359,6 +359,7 @@ private static void WriteJsvErrorToResponse(this IHttpResponse response, string
public static void ApplyGlobalResponseHeaders(this HttpListenerResponse httpRes)
{
+ if (EndpointHost.Config == null) return;
foreach (var globalResponseHeader in EndpointHost.Config.GlobalResponseHeaders)
{
httpRes.AddHeader(globalResponseHeader.Key, globalResponseHeader.Value);
@@ -367,6 +368,7 @@ public static void ApplyGlobalResponseHeaders(this HttpListenerResponse httpRes)
public static void ApplyGlobalResponseHeaders(this HttpResponse httpRes)
{
+ if (EndpointHost.Config == null) return;
foreach (var globalResponseHeader in EndpointHost.Config.GlobalResponseHeaders)
{
httpRes.AddHeader(globalResponseHeader.Key, globalResponseHeader.Value);
@@ -375,7 +377,8 @@ public static void ApplyGlobalResponseHeaders(this HttpResponse httpRes)
public static void ApplyGlobalResponseHeaders(this IHttpResponse httpRes)
{
- foreach (var globalResponseHeader in EndpointHost.Config.GlobalResponseHeaders)
+ if (EndpointHost.Config == null) return;
+ foreach (var globalResponseHeader in EndpointHost.Config.GlobalResponseHeaders)
{
httpRes.AddHeader(globalResponseHeader.Key, globalResponseHeader.Value);
}

0 comments on commit 24d5a37

Please sign in to comment.