Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Issue #1 - added wrapper call to remap hosts

  • Loading branch information...
commit 78e1741c08ac9bdb5d65e713378b2ae86704ac81 1 parent 07297f8
Adrian Hills AdaTheDev authored
44 AutomatedTester.BrowserMob/Client.cs
View
@@ -71,6 +71,28 @@ private static WebResponse MakeRequest(string url, string method, string referen
return request.GetResponse();
}
+ private static WebResponse MakeJsonRequest(string url, string method, string payload)
+ {
+ var request = (HttpWebRequest)WebRequest.Create(url);
+ request.Method = method;
+
+ if (payload != null)
+ {
+ request.ContentType = "text/json";
+ request.ContentLength = payload.Length;
+ using (var streamWriter = new StreamWriter(request.GetRequestStream()))
+ {
+ streamWriter.Write(payload);
+ streamWriter.Flush();
+ streamWriter.Close();
+ }
+ }
+ else
+ request.ContentLength = 0;
+
+ return request.GetResponse();
+ }
+
public void NewPage(string reference)
{
MakeRequest(String.Format("{0}/{1}/har/pageRef", _baseUrlProxy, _port), "PUT", reference);
@@ -117,6 +139,11 @@ public void Blacklist(string regexp, int statusCode)
MakeRequest(String.Format("{0}/{1}/blacklist", _baseUrlProxy, _port), "PUT", data);
}
+ public void RemapHost(string host, string ipAddress)
+ {
+ MakeJsonRequest(String.Format("{0}/{1}/hosts", _baseUrlProxy, _port), "POST", "{\"" + host + "\":\"" + ipAddress + "\"}");
+ }
+
private static string FormatBlackOrWhiteListFormData(string regexp, int statusCode)
{
return String.Format("regex={0}&status={1}", HttpUtility.UrlEncode(regexp), statusCode);
@@ -131,4 +158,19 @@ public void Close()
}
}
-}
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
BIN  AutomatedTester.BrowserMob/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache
View
Binary file not shown
Please sign in to comment.
Something went wrong with that request. Please try again.