public RequestTreeAgent(HttpRequestTree requestTree, ResultComparerFactory comparerFactory = null) { ServicePointManager.ServerCertificateValidationCallback = (message, certificate2, arg3, arg4) => true; _client = new HttpClient(new HttpClientHandler { ServerCertificateCustomValidationCallback = (message, certificate2, arg3, arg4) => true }); _requestTree = requestTree; _comparerFactory = comparerFactory; }
private static async Task <AgentResult> RunRequestComparisonAsync(int threads, HttpRequestTree requestTree, ResultComparerFactory comparerFactory) { CancellationTokenSource source = new CancellationTokenSource(); var token = source.Token; Console.CancelKeyPress += delegate { source.Cancel(); }; var agent = new RequestTreeAgent(requestTree, comparerFactory); return(await agent.Run(threads, token)); }
public AgentRequestGrade(ResultComparerFactory comparerFactory = null) { ComparerFactory = comparerFactory ?? new ResultComparerFactory(); }
private static async Task RunRequestTreeAgent(HttpRequestTree requestTree, int Concurrency, ResultComparerFactory comparerFactory, string requestSource, string outputFilePath) { // Draw run header Console.WriteLine(CliResultViews.StartRequestString, requestSource, Concurrency); var requestResult = await RunRequestComparisonAsync(Concurrency, requestTree, comparerFactory); var grades = requestResult.Grades; var stats = requestResult.Stats; // Draw Stats CliResultViews.DrawGrades(grades); CliResultViews.DrawStatusCodes(stats); CliResultViews.DrawStats(stats); var time = DateTime.UtcNow.ToString("yyyyMMddTHHmmss"); var result = new HttpRequestTree() { Requests = requestResult.Grades.Requests, Description = $"{requestTree.Description} : {time}" }; string outputFile = !string.IsNullOrWhiteSpace(outputFilePath) ? outputFilePath : $"output-{time}.json"; // Draw output file path Console.WriteLine("Result path: {0}", outputFile); await new SaveHttpRequestTreeToJson().Execute(result, outputFile); }