Permalink
Browse files

Merge pull request #2 from moodmosaic/master

Support for Query String through the command line arguments.
  • Loading branch information...
2 parents aa9406e + 457490b commit bf119e604b9e4d8514a4dead183e8bb5ca152805 @mikehadlow committed May 14, 2012
Showing with 10 additions and 6 deletions.
  1. +1 −0 README.txt
  2. +1 −0 src/WebStresser/HttpCallConfiguration.cs
  3. +2 −1 src/WebStresser/Program.cs
  4. +6 −5 src/WebStresser/RawHttpClient.cs
View
@@ -10,6 +10,7 @@ Options
-?, -h, --help
-u, --uri=VALUE REQUIRED: The URI you want to call
-m, --method=VALUE The HTTP method. Default is GET
+ -q, --querystring=VALUE The data to be passed. Default is empty
-i, --iterations=VALUE Number of iterations to run, default is 1
-t, --interval=VALUE Iterval between each call in milliseconds, default is 10000
-p, --postdata=VALUE Path to file containing post data
@@ -33,6 +33,7 @@ public string MethodAsString
public bool Expect100Continue { get; set; }
public bool UseNagleAlgorithm { get; set; }
+ public string QueryString { get; set; }
public HttpCallConfiguration()
{
@@ -44,6 +44,8 @@ private static OptionSet CreateOptions(HttpCallConfiguration configuration)
builder.GetServiceUri)
.Add("m=|method=", "The HTTP method. Default is GET",
builder.GetHttpMethod)
+ .Add("q=|querystring=", "The data to be passed. Default is empty",
+ option => configuration.QueryString = option ?? string.Empty)
.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",
@@ -62,7 +64,6 @@ private static OptionSet CreateOptions(HttpCallConfiguration configuration)
builder.GetTimeout)
.Add("H:", "Add a header to the request. e.g: -H MyHeader=MyValue",
builder.AddHeader);
-
}
private static void SetShowHelp(string option)
@@ -1,8 +1,8 @@
using System;
-using System.Diagnostics;
-using System.Linq;
using System.Collections.Generic;
+using System.Diagnostics;
using System.IO;
+using System.Linq;
using System.Net;
using System.Threading;
@@ -98,9 +98,10 @@ private void ExecuteRequests(object state)
}
}
- private void ExecuteRequest() {
-
- var webRequest = (HttpWebRequest)WebRequest.CreateDefault(configuration.ServiceUri);
+ private void ExecuteRequest()
+ {
+ var requestUri = new Uri(configuration.ServiceUri + configuration.QueryString);
+ var webRequest = (HttpWebRequest)WebRequest.CreateDefault(requestUri);
foreach (var headerKey in configuration.Headers.Keys)
{

0 comments on commit bf119e6

Please sign in to comment.