Exemplo n.º 1
0
        public void LoadTsvRequests(string resourceName)
        {
            var resourceStream = Assembly.GetExecutingAssembly()
                                 .GetManifestResourceStream($"Fenrir.Cli.Tests.Resources.{resourceName}");

            var requestTree = new LoadHttpRequestTreeFromListOfUrls().Execute(resourceStream);

            Request request = requestTree.Requests.FirstOrDefault();

            Assert.Equal(url, request.Url);
        }
Exemplo n.º 2
0
        public async Task Request(RequestArgs args)
        {
            HttpRequestTree requestTree = null;

            // check if we have piped
            // input
            if (Console.IsInputRedirected)
            {
                using (Stream pipeStream = Console.OpenStandardInput())
                {
                    try
                    {
                        // try load TSV
                        requestTree = new LoadHttpRequestTreeFromTsv().Execute(pipeStream);
                    }
                    catch
                    {
                        // try load Url list
                        requestTree = new LoadHttpRequestTreeFromListOfUrls().Execute(pipeStream);
                    }
                }
            }

            // load from file
            if (requestTree == null && !string.IsNullOrWhiteSpace(args.RequestFilePath))
            {
                try
                {
                    // try to load json
                    requestTree = new LoadHttpRequestTreeFromJson().Execute(args.RequestFilePath);
                }
                catch
                {
                    try
                    {
                        // try to load tsv
                        requestTree = new LoadHttpRequestTreeFromTsv().Execute(args.RequestFilePath);
                    }
                    catch
                    {
                        // try to load url list
                        requestTree = new LoadHttpRequestTreeFromListOfUrls().Execute(args.RequestFilePath);
                    }
                }
            }

            string requestSource = !string.IsNullOrWhiteSpace(args.RequestFilePath)
                ? args.RequestFilePath
                : "Pipe";

            await RunRequestTreeAgent(requestTree, args.Concurrency, null, requestSource, args.OutputFilePath);
        }