Esempio n. 1
0
        private async Task <HttpResponseMessage> ExecuteCallAsync(RestCall restCall)
        {
            Guard.ObjectNotNull(() => restCall);
            var request = _httpRequestFactory.Create(restCall);

            return(await _httpClientProxy.SendAsync(request));
        }
Esempio n. 2
0
        public XmlDocument GetXmlDocument(string url)
        {
            var request = _httpRequestFactory.Create(url);

            request.Accept = "text/xml";
            request.Method = "GET";

            var doc = new XmlDocument();

            using (var response = request.GetResponse())
            {
                doc.Load(response.GetResponseStream());
            }

            return(doc);
        }
Esempio n. 3
0
        public IHttpRequest CreateRequest(string operationName, JsonObject parameters)
        {
            if (string.IsNullOrEmpty(Uri))
            {
                throw new InvalidOperationException("You must set a Uri for the request.");
            }
            IHttpRequest webRequest = _requestFactory.Create(new Uri(Uri));

            webRequest.HttpVerb = operationName.ToHttpVerb();
            webRequest.AddHeaders(_headers);
            webRequest.AddCredentials(Credentials);
            webRequest.Accept = AcceptHeader;
            if (Proxy != null)
            {
                webRequest.Proxy = Proxy;
            }
            webRequest.AllowAutoRedirect = AllowAutoRedirect;
            webRequest.UserAgent         = UserAgent;
            webRequest.Timeout           = Timeout;

            if (_ifModifiedSince.HasValue)
            {
                ((HttpWebRequestWrapper)webRequest).IfModifiedSince = _ifModifiedSince.Value;
            }
            webRequest.AddRequestBody(ContentType, Body);

            return(webRequest);
        }
Esempio n. 4
0
        private Stream GetResponseStream(Uri uri, HttpMethod method, Stream requestStream = null)
        {
            CustomContract.Requires(uri != null);

            var request = _httpRequestFactory.Create(uri, method, _acceptHeader, _acceptHeader);

            if (requestStream != null)
            {
                request.WriteRequestStream(requestStream);
            }

            return(request.GetResponseStream());
        }
Esempio n. 5
0
        public IHttpRequest CreateRequest(string operationName, JsonObject parameters)
        {
            var uri = BuildUri(operationName, parameters);

            var webRequest = _requestFactory.Create(uri);

            webRequest.AddHeaders(_headers);
            webRequest.AddCredentials(Credentials);
            webRequest.Accept = AcceptHeader;
            webRequest.AddRequestBody(ContentType, Body);
            webRequest.AllowAutoRedirect = _allowAutoRedirect;
            webRequest.Timeout           = Timeout;

            if (_ifModifiedSince.HasValue)
            {
                ((HttpWebRequest)webRequest).IfModifiedSince = _ifModifiedSince.Value;
            }

            return(webRequest);
        }
        public string CreateShouldReturnHttpRequestWithCorrectUri(string uriString, HttpMethod httpMethod, string accept, string contentType)
        {
            var httpRequest = _httpRequestFactory.Create(new Uri(uriString), httpMethod, accept, contentType);

            var httpWebRequestAdapter = (HttpWebRequestAdapter)httpRequest;
            var actualHttpWebRequest  = (HttpWebRequest)httpWebRequestAdapter.HttpWebRequest;

            return(actualHttpWebRequest.RequestUri.ToString());
        }
        public string CreateShouldReturnHttpRequestWithCorrectUri(HttpMethod httpMethod, string contentType)
        {
            var httpRequest = _httpRequestFactory.Create(_uri, httpMethod, AcceptMimeType, contentType);

            var httpWebRequestAdapter = (HttpWebRequestAdapter)httpRequest;
            var actualHttpWebRequest  = httpWebRequestAdapter.HttpWebRequest;

            return(actualHttpWebRequest.RequestUri.ToString());
        }
Esempio n. 8
0
 private static IHttpRequest CreateRequest(IHttpRequestFactory factory, IHttpWire wire)
 {
     return(factory.Create(wire));
 }
Esempio n. 9
0
 private static IHttpRequest CreateRequest(IHttpRequestFactory factory, string url)
 {
     return(factory.Create(url));
 }
Esempio n. 10
0
 private static IHttpRequest CreateRequest(IHttpRequestFactory factory, IHttpWire wire)
 {
     return factory.Create(wire);
 }