Permalink
Browse files

Implemented limits in client and HAR info deserialized to POCO, based…

… on HAR file format v1.2
  • Loading branch information...
1 parent fffc023 commit 07297f8d53a20eec1711ad02a7955ab2a0faa5ef @AdaTheDev AdaTheDev committed Feb 19, 2012
@@ -45,6 +45,25 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Client.cs" />
+ <Compile Include="HAR\Browser.cs" />
+ <Compile Include="HAR\Cache.cs" />
+ <Compile Include="HAR\CacheEntry.cs" />
+ <Compile Include="HAR\Content.cs" />
+ <Compile Include="HAR\Cookie.cs" />
+ <Compile Include="HAR\Creator.cs" />
+ <Compile Include="HAR\Entry.cs" />
+ <Compile Include="HAR\HarResult.cs" />
+ <Compile Include="HAR\Header.cs" />
+ <Compile Include="HAR\Log.cs" />
+ <Compile Include="HAR\Page.cs" />
+ <Compile Include="HAR\PageTimings.cs" />
+ <Compile Include="HAR\Param.cs" />
+ <Compile Include="HAR\PostData.cs" />
+ <Compile Include="HAR\QueryStringItem.cs" />
+ <Compile Include="HAR\Request.cs" />
+ <Compile Include="HAR\Response.cs" />
+ <Compile Include="HAR\Timings.cs" />
+ <Compile Include="LimitOptions.cs" />
<Compile Include="Server.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
@@ -1,9 +1,9 @@
using System;
-using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Text;
using System.Web;
+using AutomatedTester.BrowserMob.HAR;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
@@ -76,7 +76,7 @@ public void NewPage(string reference)
MakeRequest(String.Format("{0}/{1}/har/pageRef", _baseUrlProxy, _port), "PUT", reference);
}
- public string GetHar()
+ public HarResult GetHar()
{
var response = MakeRequest(String.Format("{0}/{1}/har", _baseUrlProxy, _port), "GET");
using (var responseStream = response.GetResponseStream())
@@ -86,14 +86,18 @@ public string GetHar()
using (var responseStreamReader = new StreamReader(responseStream))
{
- return responseStreamReader.ReadToEnd();
+ var json = responseStreamReader.ReadToEnd();
+ return JsonConvert.DeserializeObject<HarResult>(json);
}
}
}
-
- public void Limits(Dictionary<string, int> options)
+
+ public void SetLimits(LimitOptions options)
{
+ if (options == null)
+ throw new ArgumentNullException("options", "LimitOptions must be supplied");
+ MakeRequest(String.Format("{0}/{1}/limit", _baseUrlProxy, _port), "PUT", options.ToFormData());
}
public string SeleniumProxy
@@ -0,0 +1,11 @@
+namespace AutomatedTester.BrowserMob.HAR
+{
+ public class Browser
+ {
+ public string Name { get; set; }
+
+ public string Version { get; set; }
+
+ public string Comment { get; set; }
+ }
+}
@@ -0,0 +1,11 @@
+namespace AutomatedTester.BrowserMob.HAR
+{
+ public class Cache
+ {
+ public CacheEntry BeforeRequest { get; set; }
+
+ public CacheEntry AfterRequest { get; set; }
+
+ public string Comment { get; set; }
+ }
+}
@@ -0,0 +1,17 @@
+using System;
+
+namespace AutomatedTester.BrowserMob.HAR
+{
+ public class CacheEntry
+ {
+ public DateTime? Expires { get; set; }
+
+ public DateTime LastAccess { get; set; }
+
+ public string Etag { get; set; }
+
+ public int HitCount { get; set; }
+
+ public string Comment { get; set; }
+ }
+}
@@ -0,0 +1,17 @@
+namespace AutomatedTester.BrowserMob.HAR
+{
+ public class Content
+ {
+ public int Size { get; set; }
+
+ public int? Compression { get; set; }
+
+ public string MimeType { get; set; }
+
+ public string Text { get; set; }
+
+ public string Encoding { get; set; }
+
+ public string Comment { get; set; }
+ }
+}
@@ -0,0 +1,23 @@
+using System;
+
+namespace AutomatedTester.BrowserMob.HAR
+{
+ public class Cookie
+ {
+ public string Name { get; set; }
+
+ public string Value { get; set; }
+
+ public string Path { get; set; }
+
+ public string Domain { get; set; }
+
+ public DateTime? Expires { get; set; }
+
+ public bool? HttpOnly { get; set; }
+
+ public bool? Secure { get; set; }
+
+ public string Comment { get; set; }
+ }
+}
@@ -0,0 +1,11 @@
+namespace AutomatedTester.BrowserMob.HAR
+{
+ public class Creator
+ {
+ public string Name { get; set; }
+
+ public string Version { get; set; }
+
+ public string Comment { get; set; }
+ }
+}
@@ -0,0 +1,27 @@
+using System;
+
+namespace AutomatedTester.BrowserMob.HAR
+{
+ public class Entry
+ {
+ public int Time { get; set; }
+
+ public Request Request { get; set; }
+
+ public Response Response { get; set; }
+
+ public DateTime StartedDateTime { get; set; }
+
+ public Timings Timings { get; set; }
+
+ public string PageRef { get; set; }
+
+ public Cache Cache { get; set; }
+
+ public string ServerIpAddress { get; set; }
+
+ public string Connection { get; set; }
+
+ public string Comment { get; set; }
+ }
+}
@@ -0,0 +1,7 @@
+namespace AutomatedTester.BrowserMob.HAR
+{
+ public class HarResult
+ {
+ public Log Log { get; set; }
+ }
+}
@@ -0,0 +1,11 @@
+namespace AutomatedTester.BrowserMob.HAR
+{
+ public class Header
+ {
+ public string Name { get; set; }
+
+ public string Value { get; set; }
+
+ public string Comment { get; set; }
+ }
+}
@@ -0,0 +1,17 @@
+namespace AutomatedTester.BrowserMob.HAR
+{
+ public class Log
+ {
+ public Entry[] Entries { get; set; }
+
+ public string Version { get; set; }
+
+ public Browser Browser { get; set; }
+
+ public Creator Creator { get; set; }
+
+ public Page[] Pages { get; set; }
+
+ public string Comment { get; set; }
+ }
+}
@@ -0,0 +1,17 @@
+using System;
+
+namespace AutomatedTester.BrowserMob.HAR
+{
+ public class Page
+ {
+ public string Id { get; set; }
+
+ public PageTimings PageTimings { get; set; }
+
+ public DateTime StartedDateTime { get; set; }
+
+ public string Title { get; set; }
+
+ public string Comment { get; set; }
+ }
+}
@@ -0,0 +1,11 @@
+namespace AutomatedTester.BrowserMob.HAR
+{
+ public class PageTimings
+ {
+ public int? OnContentLoad { get; set; }
+
+ public int? OnLoad { get; set; }
+
+ public string Comment { get; set; }
+ }
+}
@@ -0,0 +1,15 @@
+namespace AutomatedTester.BrowserMob.HAR
+{
+ public class Param
+ {
+ public string Name { get; set; }
+
+ public string Value { get; set; }
+
+ public string FileName { get; set; }
+
+ public string ContentType { get; set; }
+
+ public string Comment { get; set; }
+ }
+}
@@ -0,0 +1,13 @@
+namespace AutomatedTester.BrowserMob.HAR
+{
+ public class PostData
+ {
+ public string MimeType { get; set; }
+
+ public Param[] Params { get; set; }
+
+ public string Text { get; set; }
+
+ public string Comment { get; set; }
+ }
+}
@@ -0,0 +1,11 @@
+namespace AutomatedTester.BrowserMob.HAR
+{
+ public class QueryStringItem
+ {
+ public string Name { get; set; }
+
+ public string Value { get; set; }
+
+ public string Comment { get; set; }
+ }
+}
@@ -0,0 +1,25 @@
+namespace AutomatedTester.BrowserMob.HAR
+{
+ public class Request
+ {
+ public string Method { get; set; }
+
+ public QueryStringItem[] QueryString { get; set; }
+
+ public PostData PostData { get; set; }
+
+ public Cookie[] Cookies { get; set; }
+
+ public Header[] Headers { get; set; }
+
+ public int BodySize { get; set; }
+
+ public string Url { get; set; }
+
+ public string HttpVersion { get; set; }
+
+ public int HeadersSize { get; set; }
+
+ public string Comment { get; set; }
+ }
+}
@@ -0,0 +1,25 @@
+namespace AutomatedTester.BrowserMob.HAR
+{
+ public class Response
+ {
+ public Content Content { get; set; }
+
+ public Header[] Headers { get; set; }
+
+ public int Status { get; set; }
+
+ public Cookie[] Cookies { get; set; }
+
+ public int BodySize { get; set; }
+
+ public string HttpVersion { get; set; }
+
+ public int HeadersSize { get; set; }
+
+ public string StatusText { get; set; }
+
+ public string RedirectUrl { get; set; }
+
+ public string Comment { get; set; }
+ }
+}
@@ -0,0 +1,21 @@
+namespace AutomatedTester.BrowserMob.HAR
+{
+ public class Timings
+ {
+ public int? Blocked { get; set; }
+
+ public int? Dns { get; set; }
+
+ public int? Connect { get; set; }
+
+ public int Send { get; set; }
+
+ public int Wait { get; set; }
+
+ public int Receive { get; set; }
+
+ public int? Ssl { get; set; }
+
+ public string Comment { get; set; }
+ }
+}
Oops, something went wrong.

2 comments on commit 07297f8

Hi,

Can you please provide .Net calls to ReMap the hosts ?
As we have an API call "POST /proxy/[port]/hosts" but for this we don't have .net wrapped calls.
So can you please help me on this or guide me so I can do this?

Thanks,
Ramesh Jhajharia

Please sign in to comment.