Atomia.Provisioning.Modules.Haproxy.Commands.HaproxyCommandBase.REST_Execute_DELETE C# (CSharp) Method

REST_Execute_DELETE() protected method

protected REST_Execute_DELETE ( string uri ) : void
uri string
return void
        protected void REST_Execute_DELETE(string uri)
        {
            WebRequest restclient = this.REST_GetClient(uri);
            restclient.Method = "DELETE";

            try
            {

                HttpWebResponse response = (HttpWebResponse)restclient.GetResponse();
                if ((int)response.StatusCode < 200 || (int)response.StatusCode > 299)
                {
                    throw new Exception("Bad status code: " + response.StatusCode);
                }
                response.Close();
            }
            catch (WebException e)
            {
                HttpWebResponse response = (HttpWebResponse)e.Response;

                StreamReader reader = new StreamReader(response.GetResponseStream());
                string json = reader.ReadToEnd();
                reader.Close();
                response.Close();

                throw new Exception("REST request for " + uri + " failed with response: " + (int)response.StatusCode + " " + response.StatusDescription + ", the body of the response was: " + json);
            }
        }