Exemple #1
0
        protected void MakeRequest()
        {
            if (string.IsNullOrWhiteSpace(url))
            {
                throw new ArgumentNullException("url is empty");
            }

            try
            {
                /*
                 * Create new Request
                 */
                HttpWebRequest request = this.GetWebRequest(url);
                request.CookieContainer = Cookies.Container;
                request.Method          = method.ToString().ToUpper();
                if (action != null && action.Make != null)
                {
                    action.Make(request); //Pass the request out
                }
                if (headers != null)
                {
                    request.Headers = GetHeadersFromProvider(request.RequestUri, headers.GetHeaders());
                }

                if (method == HttpVerb.Get || method == HttpVerb.Head || body == null)
                {
                    ExecuteRequestWithoutBody(request);
                }
                else
                {
                    request.ContentType = body.GetContentType();
                    ExecuteRequestWithBody(request);
                }
            }
            catch (WebException webEx)
            {
                action.Fail(webEx);
            }
        }