Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions AutomatedTester.BrowserMob/Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,15 @@ public Client(string url)
var parts = url.Split(':');
_proxy = parts[1].TrimStart('/') + ":" + _port;
}

public void NewHar(string reference = null)

/// <summary>
///
/// </summary>
/// <param name="reference"></param>
/// <param name="captureContent">Whether to capture body content of requests or not</param>
public void NewHar(string reference = null, bool captureContent = false)
{
MakeRequest(String.Format("{0}/{1}/har", _baseUrlProxy, _port), "PUT", reference);
MakeRequest(String.Format("{0}/{1}/har" + (captureContent ? "?captureContent=true" : ""), _baseUrlProxy, _port), "PUT", reference);
}

private static WebResponse MakeRequest(string url, string method, string reference = null)
Expand Down
6 changes: 4 additions & 2 deletions AutomatedTester.BrowserMob/Server.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public class Server
private readonly int _port;
private readonly String _path = string.Empty;
private const string Host = "localhost";
private string _errorMessage = "";

public Server(string path) : this(path, 8080)
{}
Expand Down Expand Up @@ -43,7 +44,7 @@ public void Start()
count++;
if (count == 30)
{
throw new Exception("Can not connect to BrowserMob Proxy");
throw new Exception($"Can not connect to BrowserMob Proxy - {_errorMessage}");
}
}
}
Expand Down Expand Up @@ -96,8 +97,9 @@ private bool IsListening()
socket.Close();
return true;
}
catch (Exception)
catch (Exception ex)
{
_errorMessage = ex.Message;
return false;
}
}
Expand Down