Blaze.Controllers.HomeController.Proxy C# (CSharp) Method

Proxy() private method

private Proxy ( string account, string url, string auth ) : System.Web.Mvc.ActionResult
account string
url string
auth string
return System.Web.Mvc.ActionResult
        public ActionResult Proxy(string account, string url, string auth)
        {
            string fullUrl = string.Format("https://{0}.campfirenow.com/{1}?{2}", account, url, Request["QUERY_STRING"]);
            var request = (HttpWebRequest) WebRequest.Create(fullUrl);
            request.Method = Request.HttpMethod;
            request.ContentType = Request.ContentType;
            request.ContentLength = Request.ContentLength;

            if (!string.IsNullOrEmpty(auth))
                request.Headers["Authorization"] = "Bearer " + auth;
            request.Accept = Request.Headers["Accept"];

            if (Request.HttpMethod == "POST" || Request.HttpMethod == "PUT")
            {
                var inStream = Request.InputStream;
                var outStream = request.GetRequestStream();
                inStream.CopyTo(outStream);
                outStream.Close();
            }
            try
            {
                var response = (HttpWebResponse) request.GetResponse();
                Response.StatusCode = (int) response.StatusCode;
                var reader = new StreamReader(response.GetResponseStream());
                var data = reader.ReadToEnd();
                data = commandWrappers
                    .Where(commandWrapper => commandWrapper.Match(url))
                    .Aggregate(data, (current, commandWrapper) => commandWrapper.ProcessContent(Request,GetIPAddress(Request), account, current));
                return Content(data, response.ContentType);
            } catch (WebException ex)
            {
                return HandleWebException(fullUrl, ex);
            }
        }