public UriPatternMatchType Match(RequestProperties properties, out UriPattern matchedPattern) { var result = UriPatternMatchType.NonMatch; UriPattern output = null; Parallel.ForEach(this._exceptionPatterns, (p, state) => { if (p.Match(properties) == UriPatternMatchType.Exception) { state.Stop(); output = p; result = UriPatternMatchType.Exception; } }); if (result == UriPatternMatchType.Exception) { matchedPattern = output; return(result); } Parallel.ForEach(this._matchPatterns, (p, state) => { if (p.Match(properties) == UriPatternMatchType.Match) { state.Stop(); output = p; result = UriPatternMatchType.Match; } }); matchedPattern = output; return(result); }
public UriPatternMatchType Match(RequestProperties properties, out UriPattern matchedPattern) { var result = UriPatternMatchType.NonMatch; UriPattern output = null; Parallel.ForEach(this._exceptionPatterns, (p, state) => { if (p.Match(properties) == UriPatternMatchType.Exception) { state.Stop(); output = p; result = UriPatternMatchType.Exception; } }); if (result == UriPatternMatchType.Exception) { matchedPattern = output; return result; } Parallel.ForEach(this._matchPatterns, (p, state) => { if (p.Match(properties) == UriPatternMatchType.Match) { state.Stop(); output = p; result = UriPatternMatchType.Match; } }); matchedPattern = output; return result; }
/// <summary> /// The fiddler application before response. /// </summary> /// <param name="session"> /// The session. /// </param> private void FiddlerApplicationBeforeResponse(Session session) { var requestProperties = new RequestProperties(session.fullUrl, session.oRequest.headers["Referer"], session.oRequest.headers["Accept"]); var filteredRules = from r in this.ResponseRules where r.Enabled where r.Matches == null || UriPattern.Match(requestProperties, r.Matches) select r; (from rule in filteredRules let rule1 = rule where rule.ResponseActions.Any(action => action.Enabled && !action.OnResponse(session, rule1)) select rule).Any(); if (this.ResponseReceived != null) { this.ResponseReceived( session, new ResponseSummaryEventArgs { ResponseCode = session.responseCode, FullUrl = session.fullUrl, ResponseCodeText = session.oResponse.headers.HTTPResponseStatus, Referer = (session.oRequest["Referer"].HasValue() ? session.oRequest["Referer"] : "None") + ", Sessions: " + this.SessionCount, Length = session.ResponseBody.LongLength }); } }
/// <summary> /// The fiddler application before request. /// </summary> /// <param name="session"> /// The session. /// </param> private void FiddlerApplicationBeforeRequest(Session session) { Interlocked.Increment(ref this._sessionCount); var requestProperties = new RequestProperties(session.fullUrl, session.oRequest.headers["Referer"], session.oRequest.headers["Accept"]); if (requestProperties.Uri == null) { // Malformed URI, let's terminate the request. session.oRequest.FailSession(400, "Bad Request (Malformed Uri)", String.Empty); return; } var filteredRules = from r in this.RequestRules where r.Enabled where r.Matches == null || UriPattern.Match(requestProperties, r.Matches) select r; foreach (var rule in filteredRules.Where(rule => rule.RequestActions.Any(action => action.Enabled && !action.BeforeRequest(session, rule)))) { break; } }