Beispiel #1
0
        private string BuildUrl(Request request)
        {
            if (request.UrlParameters == null || request.UrlParameters.Count == 0)
            {
                return string.Empty;
            }

            string result = "?";

            foreach (var urlParameter in request.UrlParameters)
            {
                result += string.Format("{0}={1}&", urlParameter.Key, urlParameter.Value);
            }

            return string.Format("{0}{1}", request.Uri, result.TrimEnd(new[] {'&'}));
        }
Beispiel #2
0
        private HttpRequestMessage BuildRequest(Request request)
        {
            var requestMessage = new HttpRequestMessage(
                HttpMethodExtensions.FromString(request.Method),
                BuildUrl(request));

            foreach (var header in request.Headers)
            {
                requestMessage.Headers.Add(header.Key, header.Value);
            }

            if (request.Method != "GET")
            {
                requestMessage.Content = BuildContent(request);
            }

            return requestMessage;
        }
Beispiel #3
0
        private HttpContent BuildContent(Request request)
        {
            if (string.IsNullOrEmpty(request.Body)) {  return new StringContent(string.Empty); }

            return new StringContent(request.Body);
        }
Beispiel #4
0
 public EsthR Send(Request request)
 {
     _lastRequest = BuildRequest(request);
     return this;
 }