public void DeleteProxy() { Log.Message("Deleting proxy on port " + proxyPort); request.Method = Method.DELETE; request.Resource = string.Format("/proxy/{0}", proxyPort); response = client.Execute(request); if (response.StatusCode != HttpStatusCode.OK) { throw new Exception("Could not delete proxy at port : " + proxyPort + " : " + response.StatusCode); } }
public void CreateHar() { Log.Message("Creating a new Har"); request.Method = Method.PUT; request.Resource = string.Format("/proxy/{0}/har", proxyPort); response = client.Execute(request); if (response.ResponseStatus != ResponseStatus.Completed) { throw new Exception("Could not create Har on port " + proxyPort + ": " + response.StatusCode); } }
public void CreatePage(string name) { Log.Message("Creating a new Proxy Page with name " + name); request.Method = Method.PUT; request.Resource = string.Format("/proxy/{0}/har/pageRef", proxyPort); response = client.Execute(request); if (response.StatusCode != HttpStatusCode.OK) { throw new Exception("Could not create Page : " + response.StatusCode); } }
public void QuitProxy() { Log.Message("Quitting Proxy on Port " + proxyPort); request.Method = Method.DELETE; request.Resource = "/proxy/" + proxyPort; response = client.Execute(request); if (response.StatusCode != HttpStatusCode.OK) { Log.Warning("Could not quit proxy on port : " + proxyPort); } }
public void UnzipProxy() { if (File.Exists(batchPath) == false) { Log.Message("BrowserMobProxy not found, unzipping"); //using (var zf = ZipFile.Read(zipPath)) //{ // zf.ExtractAll(extractPath); //} } }
public void QuitServer() { try { Log.Message("Stopping BrowserMobProxy Server"); serverProcess.CloseMainWindow(); serverProcess.Kill(); server_started = false; } catch (Exception e) { Log.Error(e.Message); } }
public void CreateProxy() { if (server_started == false) { StartServer(); } Log.Message("Creating Proxy on Port " + proxyPort); request.Method = Method.POST; request.Resource = "/proxy?port=" + proxyPort; response = client.Execute(request); if (response.StatusCode != HttpStatusCode.OK) { response = client.Execute(request); if (response.StatusCode != HttpStatusCode.OK) { throw new Exception("Could not start Proxy at port : " + proxyPort + " : " + response.ErrorMessage); } } }
public void KillOldProxy() { if (Config.settings.httpProxy.killOldProxy) { var runningProcesses = Process.GetProcesses(); foreach (var process in runningProcesses) { try { if ((process.ProcessName == "java") && (process.StartInfo.CreateNoWindow == false)) { Log.Message("Killing old BMP Proxy"); process.Kill(); } } catch (Exception) { } } } }
public void VerifyRequestQueryString(string url, QueryStringItem queryString) { if (IsQueryStringInEntry(queryString, GetLastEntryForUrl(url))) { Log.Message(string.Format("!--Verification Passed. Request contains {0}={1}", queryString.Name, queryString.Value)); return; } string message; var value = GetValueForQueryStringWithName(queryString.Name, GetLastEntryForUrl(url)); if (value != null) { message = string.Format("Expected {0}={1}. Actual {2}={3}", queryString.Name, queryString.Value, queryString.Name, value); } else { message = string.Format("No QueryString found with Description={0}", queryString.Name); } TestBase.AddVerificationError(string.Format("Request From {0} to {1} not correct. {2}", TestBase.testData.driver.Url, url, message)); }