示例#1
0
 public ConfigurationBuilder(HttpCallConfiguration configuration)
 {
     this.configuration = configuration;
 }
示例#2
0
        public static void Main(string[] args)
        {
            var configuration = new HttpCallConfiguration();
            var optionSet = CreateOptions(configuration);

            try
            {
                optionSet.Parse(args);
                if (!configuration.IsValid())
                {
                    throw new OptionException("Missing required parameters", "");
                }

                var client = new RawHttpClient(configuration, Console.Out);
                client.MakeRawHttpCall();
            }
            catch (OptionException exception)
            {
                Console.WriteLine(exception.Message);
                ShowHelp(optionSet);
            }
        }
示例#3
0
        private static OptionSet CreateOptions(HttpCallConfiguration configuration)
        {
            var builder = new ConfigurationBuilder(configuration);

            return new OptionSet()
                .Add("?|h|help", SetShowHelp)
                .Add("u=|uri=", "REQUIRED: The URI you want to call",
                    builder.GetServiceUri)
                .Add("m=|method=", "The HTTP method. Default is GET",
                    builder.GetHttpMethod)
                .Add("i=|iterations=", "Number of iterations to run, default is 1",
                    builder.GetIterations)
                .Add("t=|interval=", "Iterval between each call in milliseconds, default is 10000",
                    builder.GetInterval)
                .Add("p=|postdata=", "Path to file containing post data",
                    builder.LoadPostData)
                .Add("r|responses", "Print responses",
                    option => configuration.PrintResponse = (option != null))
                .Add("k|keepalive", "KeepAlive header value (true or false), default is true",
                    builder.GetKeepAlive)
                .Add("a=|accept=", "Accept header value, default is 'text/xml'",
                    option => configuration.Accept = option ?? "text/xml")
                .Add("c=|contenttype=", "ContentType header value, default is 'text/xml;charset=\"utf-8\"'",
                    option => configuration.ContentType = option ?? "text/xml;charset=\"utf-8\"")
                .Add("z=|timeout=", "Timeout in milliseconds, default is 10000",
                    builder.GetTimeout)
                .Add("H:", "Add a header to the request. e.g: -H MyHeader=MyValue",
                    builder.AddHeader);
        }
示例#4
0
 public RawHttpClient(HttpCallConfiguration configuration, TextWriter outputWriter)
 {
     this.configuration = configuration;
     this.outputWriter = outputWriter;
 }