internal void OnPreSendRequestHeaders(HttpContextBase context) { if (!this.isEnabled) { return; } Diagnostics.SendWatsonReportOnUnhandledException(delegate() { if (NativeProxyHelper.CanNativeProxyHandleRequest(context.ApplicationInstance.Context) && context.Response.StatusCode == 200) { this.AddCookiesToClientResponse(context); } }, new Diagnostics.LastChanceExceptionHandler(this.LastChanceExceptionHandler)); }
internal void OnPostAuthorizeRequest(HttpContextBase context) { if (!this.isEnabled) { return; } Diagnostics.SendWatsonReportOnUnhandledException(delegate() { if (NativeProxyHelper.CanNativeProxyHandleRequest(context.ApplicationInstance.Context)) { NativeProxyHelper.UpdateRequestHeaders(context.ApplicationInstance.Context); } }, new Diagnostics.LastChanceExceptionHandler(this.LastChanceExceptionHandler)); }
protected virtual void OnPostAuthorizeInternal(HttpApplication httpApplication) { HttpContext context = httpApplication.Context; if (NativeProxyHelper.CanNativeProxyHandleRequest(context)) { RequestDetailsLoggerBase <RequestDetailsLogger> .SafeAppendGenericInfo(RequestDetailsLoggerBase <RequestDetailsLogger> .GetCurrent(context), "ProxyRequestHandler", "NativeHttpProxy"); return; } IHttpHandler httpHandler; if (context.Request.IsAuthenticated) { httpHandler = this.SelectHandlerForAuthenticatedRequest(context); } else { httpHandler = this.SelectHandlerForUnauthenticatedRequest(context); } if (httpHandler != null) { if (Microsoft.Exchange.Diagnostics.Components.HttpProxy.ExTraceGlobals.VerboseTracer.IsTraceEnabled(TraceType.DebugTrace)) { Microsoft.Exchange.Diagnostics.Components.HttpProxy.ExTraceGlobals.VerboseTracer.TraceDebug <Type, object>((long)this.GetHashCode(), "[ProxyModule::OnPostAuthorizeInternal]: The selected HttpHandler is {0}; Context {1};", httpHandler.GetType(), context.Items[Constants.TraceContextKey]); } PerfCounters.HttpProxyCountersInstance.TotalRequests.Increment(); if (httpHandler is ProxyRequestHandler) { ((ProxyRequestHandler)httpHandler).Run(context); } else { context.RemapHandler(httpHandler); } long currentLatency = LatencyTracker.FromHttpContext(context).GetCurrentLatency(LatencyTrackerKey.ProxyModuleLatency); if (currentLatency > 100L) { RequestDetailsLoggerBase <RequestDetailsLogger> .SafeAppendGenericInfo(RequestDetailsLoggerBase <RequestDetailsLogger> .GetCurrent(context), "RemapHandler", currentLatency); } } }
// 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)); }
// Token: 0x060005F2 RID: 1522 RVA: 0x00021190 File Offset: 0x0001F390 private static void FinalizeRequestLatencies(HttpContext httpContext, RequestDetailsLogger requestDetailsLogger, IActivityScope activityScope, LatencyTracker tracker, int traceContext) { if (tracker == null) { return; } if (requestDetailsLogger == null) { throw new ArgumentNullException("requestDetailsLogger"); } if (activityScope == null) { throw new ArgumentNullException("activityScope"); } if (httpContext == null) { throw new ArgumentNullException("httpContext"); } HttpContextBase wrapper = SharedHttpContextWrapper.GetWrapper(httpContext); long num = tracker.GetCurrentLatency(LatencyTrackerKey.ProxyModuleLatency); if (num >= 0L) { long num2 = 0L; long.TryParse(activityScope.GetProperty(6), out num2); long num3 = 0L; bool flag = requestDetailsLogger.TryGetLatency(37, ref num3); long num4 = requestDetailsLogger.GetLatency(34, 0L) + requestDetailsLogger.GetLatency(36, 0L) + num3 + requestDetailsLogger.GetLatency(39, 0L) + requestDetailsLogger.GetLatency(40, 0L); long num5 = num - num4; if (!NativeProxyHelper.WasProxiedByNativeProxyHandler(wrapper)) { PerfCounters.UpdateMovingAveragePerformanceCounter(PerfCounters.HttpProxyCountersInstance.MovingAverageCasLatency, num5); } RequestDetailsLoggerBase <RequestDetailsLogger> .SafeSetLogger(requestDetailsLogger, 43, num5); long num6 = num5 - num2; if (flag) { RequestDetailsLoggerBase <RequestDetailsLogger> .SafeSetLogger(requestDetailsLogger, 42, Math.Max(num6, 0L)); string property = activityScope.GetProperty(13); if (PerfCounters.RoutingLatenciesEnabled && !string.IsNullOrEmpty(property)) { string empty = string.Empty; Utilities.TryExtractForestFqdnFromServerFqdn(property, ref empty); PercentilePerfCounters.UpdateRoutingLatencyPerfCounter(empty, (double)num6); PerfCounters.GetHttpProxyPerForestCountersInstance(empty).TotalProxyWithLatencyRequests.Increment(); } } long val = num6 - requestDetailsLogger.GetLatency(35, 0L) - requestDetailsLogger.GetLatency(38, 0L); RequestDetailsLoggerBase <RequestDetailsLogger> .SafeSetLogger(requestDetailsLogger, 41, Math.Max(val, 0L)); long currentLatency = tracker.GetCurrentLatency(LatencyTrackerKey.ProxyModuleLatency); long num7 = currentLatency - num; num = currentLatency; if (num7 > 5L) { RequestDetailsLoggerBase <RequestDetailsLogger> .SafeAppendGenericInfo(requestDetailsLogger, "TotalRequestTimeDelta", num7); } } RequestDetailsLoggerBase <RequestDetailsLogger> .SafeSetLogger(requestDetailsLogger, 16, num); }