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[] {'&'})); }
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; }
private HttpContent BuildContent(Request request) { if (string.IsNullOrEmpty(request.Body)) { return new StringContent(string.Empty); } return new StringContent(request.Body); }
public EsthR Send(Request request) { _lastRequest = BuildRequest(request); return this; }