Beispiel #1
0
        // Token: 0x060005F8 RID: 1528 RVA: 0x00021AE4 File Offset: 0x0001FCE4
        private void OnPostAuthorizeRequest(object sender, EventArgs e)
        {
            HttpApplication httpApplication = (HttpApplication)sender;
            HttpContext     httpContext     = httpApplication.Context;

            CheckpointTracker.GetOrCreate(httpContext.Items).Add(FrontEndHttpProxyCheckpoints.ProxyModulePostAuthorizeRequest);
            Diagnostics.SendWatsonReportOnUnhandledException(delegate()
            {
                if (ExTraceGlobals.VerboseTracer.IsTraceEnabled(1))
                {
                    ExTraceGlobals.VerboseTracer.TraceDebug((long)this.GetHashCode(), "[ProxyModule::OnPostAuthorizeRequest]: Method {0}; Url {1}; Username {2}; Context {3};", new object[]
                    {
                        httpContext.Request.HttpMethod,
                        httpContext.Request.Url,
                        (httpContext.User == null) ? string.Empty : IIdentityExtensions.GetSafeName(httpContext.User.Identity, true),
                        httpContext.GetTraceContext()
                    });
                }
                this.OnPostAuthorizeInternal(httpApplication);
                LatencyTracker latencyTracker = LatencyTracker.FromHttpContext(httpContext);
                RequestDetailsLoggerBase <RequestDetailsLogger> .SafeSetLogger(RequestDetailsLoggerBase <RequestDetailsLogger> .GetCurrent(httpContext), 6, latencyTracker.GetCurrentLatency(LatencyTrackerKey.ProxyModuleLatency));
                long currentLatency = latencyTracker.GetCurrentLatency(LatencyTrackerKey.AuthenticationLatency);
                PerfCounters.UpdateMovingAveragePerformanceCounter(PerfCounters.HttpProxyCountersInstance.MovingAverageAuthenticationLatency, currentLatency);
                latencyTracker.StartTracking(LatencyTrackerKey.ModuleToHandlerSwitchingLatency, false);
            }, new Diagnostics.LastChanceExceptionHandler(RequestDetailsLogger.LastChanceExceptionHandler));
        }
Beispiel #2
0
        // Token: 0x060005F7 RID: 1527 RVA: 0x00021A78 File Offset: 0x0001FC78
        private void OnBeginRequest(object sender, EventArgs e)
        {
            HttpApplication httpApplication = (HttpApplication)sender;
            HttpContext     httpContext     = httpApplication.Context;

            CheckpointTracker.GetOrCreate(httpContext.Items).Add(FrontEndHttpProxyCheckpoints.ProxyModuleBeginRequest);
            Diagnostics.SendWatsonReportOnUnhandledException(delegate()
            {
                LatencyTracker latencyTracker = new LatencyTracker();
                latencyTracker.StartTracking(LatencyTrackerKey.ProxyModuleLatency, false);
                AspNetHelper.AddTimestampHeaderIfNecessary(httpContext.Request.Headers, "X-FrontEnd-Begin");
                if (ExTraceGlobals.VerboseTracer.IsTraceEnabled(1))
                {
                    ExTraceGlobals.VerboseTracer.TraceDebug <string, Uri, int>((long)this.GetHashCode(), "[ProxyModule::OnBeginRequest]: Method {0}; Url {1}; Context {2};", httpContext.Request.HttpMethod, httpContext.Request.Url, httpContext.GetHashCode());
                }
                if (HealthCheckResponder.Instance.IsHealthCheckRequest(httpContext))
                {
                    HealthCheckResponder.Instance.CheckHealthStateAndRespond(httpContext);
                    return;
                }
                RequestDetailsLogger requestDetailsLogger = RequestDetailsLoggerBase <RequestDetailsLogger> .InitializeRequestLogger();
                requestDetailsLogger.LogCurrentTime("BeginRequest");
                httpContext.Items[Constants.TraceContextKey] = httpContext.GetHashCode();
                httpContext.Items[Constants.LatencyTrackerContextKeyName] = latencyTracker;
                requestDetailsLogger.ActivityScope.UpdateFromMessage(httpContext.Request);
                requestDetailsLogger.ActivityScope.SerializeTo(httpContext.Response);
                RequestDetailsLoggerBase <RequestDetailsLogger> .SetCurrent(httpContext, requestDetailsLogger);
                httpContext.Items[typeof(ActivityScope)] = requestDetailsLogger.ActivityScope;
                httpContext.Items[Constants.RequestIdHttpContextKeyName] = requestDetailsLogger.ActivityScope.ActivityId;
                RequestDetailsLoggerBase <RequestDetailsLogger> .SafeSetLogger(requestDetailsLogger, 6, HttpProxyGlobals.ProtocolType);
                requestDetailsLogger.SafeLogUriData(httpContext.Request.Url);
                RequestDetailsLoggerBase <RequestDetailsLogger> .SafeSetLogger(requestDetailsLogger, 6, httpContext.Request.HttpMethod);
                string requestCorrelationId = AspNetHelper.GetRequestCorrelationId(httpContext);
                RequestDetailsLoggerBase <RequestDetailsLogger> .SafeAppendGenericInfo(requestDetailsLogger, "CorrelationID", requestCorrelationId);
                httpContext.Response.AppendToLog(Constants.CorrelationIdKeyForIISLogs + requestCorrelationId + ";");
                UrlUtilities.SaveOriginalRequestHostSchemePortToContext(SharedHttpContextWrapper.GetWrapper(httpContext));
                try
                {
                    this.OnBeginRequestInternal(httpApplication);
                }
                catch (Exception ex)
                {
                    RequestDetailsLoggerBase <RequestDetailsLogger> .SafeAppendGenericError(requestDetailsLogger, "OnBeginRequestInternal", ex.ToString());
                    requestDetailsLogger.AsyncCommit(false, false);
                    throw;
                }
            }, new Diagnostics.LastChanceExceptionHandler(RequestDetailsLogger.LastChanceExceptionHandler));
        }
Beispiel #3
0
        // Token: 0x060005FA RID: 1530 RVA: 0x00021B74 File Offset: 0x0001FD74
        private void OnPreSendRequestHeaders(object sender, EventArgs e)
        {
            HttpApplication httpApplication = (HttpApplication)sender;
            HttpContext     httpContext     = httpApplication.Context;

            CheckpointTracker.GetOrCreate(httpContext.Items).Add(FrontEndHttpProxyCheckpoints.ProxyModulePreSendRequestHeaders);
            Diagnostics.SendWatsonReportOnUnhandledException(delegate()
            {
                if (httpContext != null && httpContext.Response != null && httpContext.Response.Headers != null)
                {
                    AspNetHelper.AddTimestampHeaderIfNecessary(httpContext.Response.Headers, "X-FrontEnd-End");
                    RequestDetailsLogger current = RequestDetailsLoggerBase <RequestDetailsLogger> .GetCurrent(httpContext);
                    if (current != null && !current.IsDisposed)
                    {
                        this.SetResponseHeaders(current, httpContext);
                    }
                    if (Extensions.IsProbeRequest(Extensions.GetHttpRequestBase(httpContext.Request)) && !RequestFailureContext.IsSetInResponse(SharedHttpContextWrapper.GetWrapper(httpContext).Response))
                    {
                        RequestFailureContext requestFailureContext = null;
                        if (httpContext.Items.Contains(RequestFailureContext.HttpContextKeyName))
                        {
                            requestFailureContext = (RequestFailureContext)httpContext.Items[RequestFailureContext.HttpContextKeyName];
                        }
                        else if (httpContext.Response.StatusCode >= 400 && httpContext.Response.StatusCode < 600)
                        {
                            LiveIdAuthResult?liveIdAuthResult = null;
                            LiveIdAuthResult value;
                            if (httpContext.Items.Contains("LiveIdBasicAuthResult") && Enum.TryParse <LiveIdAuthResult>((string)httpContext.Items["LiveIdBasicAuthResult"], true, out value))
                            {
                                liveIdAuthResult = new LiveIdAuthResult?(value);
                            }
                            requestFailureContext = new RequestFailureContext(1, httpContext.Response.StatusCode, httpContext.Response.StatusDescription, string.Empty, null, null, liveIdAuthResult);
                        }
                        if (requestFailureContext != null)
                        {
                            requestFailureContext.UpdateResponse(SharedHttpContextWrapper.GetWrapper(httpContext).Response);
                        }
                    }
                    ProxyRequestHandler proxyRequestHandler = httpContext.CurrentHandler as ProxyRequestHandler;
                    if (proxyRequestHandler != null)
                    {
                        proxyRequestHandler.ResponseHeadersSent = true;
                    }
                }
            }, new Diagnostics.LastChanceExceptionHandler(RequestDetailsLogger.LastChanceExceptionHandler));
        }
Beispiel #4
0
        // Token: 0x060005F6 RID: 1526 RVA: 0x00021A0C File Offset: 0x0001FC0C
        private void OnAuthenticateRequest(object sender, EventArgs e)
        {
            HttpApplication httpApplication = (HttpApplication)sender;
            HttpContext     httpContext     = httpApplication.Context;

            CheckpointTracker.GetOrCreate(httpContext.Items).Add(FrontEndHttpProxyCheckpoints.ProxyModuleAuthenticateRequest);
            Diagnostics.SendWatsonReportOnUnhandledException(delegate()
            {
                LatencyTracker.FromHttpContext(httpContext).StartTracking(LatencyTrackerKey.AuthenticationLatency, false);
                if (ExTraceGlobals.VerboseTracer.IsTraceEnabled(1))
                {
                    ExTraceGlobals.VerboseTracer.TraceDebug <string, Uri, object>((long)this.GetHashCode(), "[ProxyModule::OnAuthenticateRequest]: Method {0}; Url {1}; Context {2};", httpContext.Request.HttpMethod, httpContext.Request.Url, httpContext.Items[Constants.TraceContextKey]);
                }
                this.OnAuthenticateInternal(httpApplication);
                long currentLatency = LatencyTracker.FromHttpContext(httpContext).GetCurrentLatency(LatencyTrackerKey.ProxyModuleLatency);
                if (currentLatency > 100L)
                {
                    RequestDetailsLoggerBase <RequestDetailsLogger> .SafeAppendGenericInfo(RequestDetailsLoggerBase <RequestDetailsLogger> .GetCurrent(httpContext), "OnAuthenticate", currentLatency);
                }
            }, new Diagnostics.LastChanceExceptionHandler(RequestDetailsLogger.LastChanceExceptionHandler));
        }
Beispiel #5
0
        // Token: 0x060005FB RID: 1531 RVA: 0x00021BD8 File Offset: 0x0001FDD8
        private void OnEndRequest(object sender, EventArgs e)
        {
            HttpApplication httpApplication = (HttpApplication)sender;
            HttpContext     httpContext     = httpApplication.Context;

            CheckpointTracker.GetOrCreate(httpContext.Items).Add(FrontEndHttpProxyCheckpoints.ProxyModuleEndRequest);
            Diagnostics.SendWatsonReportOnUnhandledException(delegate()
            {
                if (!HostHeaderValidator.HasValidHostHeaderStatusDescription(new HttpContextWrapper(httpContext).Response) || httpContext.Items["AutodiscoverRedirectModule"] != null)
                {
                    return;
                }
                LatencyTracker latencyTracker = LatencyTracker.FromHttpContext(httpContext);
                RequestDetailsLogger current  = RequestDetailsLoggerBase <RequestDetailsLogger> .GetCurrent(httpContext);
                RequestDetailsLoggerBase <RequestDetailsLogger> .SafeAppendGenericInfo(RequestDetailsLoggerBase <RequestDetailsLogger> .GetCurrent(httpContext), GuardedSharedCacheExecution.Default.Key, GuardedSharedCacheExecution.Default.Guard.GetCurrentValue());
                int traceContext = httpContext.GetTraceContext();
                if (httpContext.Response != null && current != null)
                {
                    httpContext.Response.AppendToLog(Constants.RequestIdKeyForIISLogs + current.ActivityId.ToString() + ";");
                }
                if (HealthCheckResponder.Instance.IsHealthCheckRequest(httpContext))
                {
                    return;
                }
                if (httpContext.Response.StatusCode == 404 && httpContext.Response.SubStatusCode == 13)
                {
                    httpContext.Response.StatusCode = 507;
                }
                if (ExTraceGlobals.VerboseTracer.IsTraceEnabled(1))
                {
                    ExTraceGlobals.VerboseTracer.TraceDebug((long)this.GetHashCode(), "[ProxyModule::OnEndRequest]: Method {0}; Url {1}; Username {2}; Context {3};", new object[]
                    {
                        httpContext.Request.HttpMethod,
                        httpContext.Request.Url,
                        (httpContext.User == null) ? string.Empty : IIdentityExtensions.GetSafeName(httpContext.User.Identity, true),
                        traceContext
                    });
                }
                if (latencyTracker != null)
                {
                    long currentLatency = latencyTracker.GetCurrentLatency(LatencyTrackerKey.HandlerToModuleSwitchingLatency);
                    if (currentLatency >= 0L)
                    {
                        RequestDetailsLoggerBase <RequestDetailsLogger> .SafeSetLogger(current, 5, currentLatency);
                    }
                }
                ProxyRequestHandler proxyRequestHandler = httpContext.CurrentHandler as ProxyRequestHandler;
                if (proxyRequestHandler != null && !proxyRequestHandler.IsDisposed)
                {
                    current.AppendGenericInfo("DisposeProxyRequestHandler", "ProxyModule::OnEndRequest");
                    proxyRequestHandler.Dispose();
                }
                ProxyModule.InspectNativeProxyFatalError(httpContext.Response, current);
                string text = httpContext.Items["AnonymousRequestFilterModule"] as string;
                if (!string.IsNullOrEmpty(text))
                {
                    current.AppendGenericInfo("AnonymousRequestFilterModule", text);
                }
                try
                {
                    this.OnEndRequestInternal(httpApplication);
                }
                finally
                {
                    if (current != null && !current.IsDisposed)
                    {
                        IActivityScope activityScope = current.ActivityScope;
                        if (activityScope != null)
                        {
                            if (!string.IsNullOrEmpty(activityScope.TenantId))
                            {
                                httpContext.Items["AuthenticatedUserOrganization"] = activityScope.TenantId;
                            }
                            ProxyModule.FinalizeRequestLatencies(httpContext, current, activityScope, latencyTracker, traceContext);
                        }
                        current.LogCurrentTime("EndRequest");
                        RequestDetailsLoggerBase <RequestDetailsLogger> .SafeSetLogger(current, 0, DateTime.UtcNow);
                        current.AsyncCommit(false, NativeProxyHelper.WasProxiedByNativeProxyHandler(SharedHttpContextWrapper.GetWrapper(httpContext)));
                    }
                    if (ExTraceGlobals.VerboseTracer.IsTraceEnabled(1))
                    {
                        ExTraceGlobals.VerboseTracer.TraceDebug(0L, "[ProxyModule::OnEndRequest]: Method {0}; Url {1}; OnEndRequestLatency {2}; Context {3};", new object[]
                        {
                            httpContext.Request.HttpMethod,
                            httpContext.Request.Url,
                            (latencyTracker != null) ? latencyTracker.GetCurrentLatency(LatencyTrackerKey.ProxyModuleLatency).ToString() : "Unknown",
                            traceContext
                        });
                    }
                }
            }, new Diagnostics.LastChanceExceptionHandler(RequestDetailsLogger.LastChanceExceptionHandler));
        }