Exemplo n.º 1
0
        public ProxyApi(string url)
        {
            _api          = new ApiObject();
            _url          = url;
            _baseUrlProxy = $"http://{_url}:32006/proxy";
            using (var response = _api.MakeRequest(_baseUrlProxy, "POST"))
            {
                var responseStream = response.GetResponseStream();
                if (responseStream == null)
                {
                    throw new Exception("No response from proxy");
                }

                using (var responseStreamReader = new StreamReader(responseStream))
                {
                    var jsonReader = new JsonTextReader(responseStreamReader);
                    var token      = JToken.ReadFrom(jsonReader);
                    var portToken  = token.SelectToken("port");
                    if (portToken == null)
                    {
                        throw new Exception("No port number returned from proxy");
                    }

                    _port = (Int16)portToken;
                }
            }

            _proxy = _url.TrimStart('/') + ":" + _port;
        }
Exemplo n.º 2
0
 public void NewHar(string reference = null, string query = "")
 {
     _api.MakeRequest(String.Format("{0}/{1}/har" + query, _baseUrlProxy, _port), "PUT", reference);
 }