Permalink
Browse files

Added support for Query String in options. The user can specify data …

…to be passed by using either -q or -querystring. The query string is composed of a series of field-value pairs. For more than one field-value pairs quote the Query String with ". ex.: Single field-value pair: -q=?username=foo Multiple field-values pairs: -q="?username=foo&password=bar"
  • Loading branch information...
moodmosaic committed May 14, 2012
1 parent aa9406e commit 82278796a6f07fa267205650820acc73206dab3d
Showing with 9 additions and 6 deletions.
  1. +1 −0 src/WebStresser/HttpCallConfiguration.cs
  2. +2 −1 src/WebStresser/Program.cs
  3. +6 −5 src/WebStresser/RawHttpClient.cs
@@ -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 8227879

Please sign in to comment.