private HttpRequestMessage CreateHttpRequest(Request request, IAuthenticator authenticator) { var httpRequest = new HttpRequestMessage(request.Method, new Uri(request.Uri)); if (request.Method == HttpMethod.Post || request.Method == HttpMethod.Put) { var contentRequest = request as ContentRequest; if (contentRequest != null && !string.IsNullOrEmpty(contentRequest.Content) && contentRequest.Encoding != null && !string.IsNullOrEmpty(contentRequest.MediaType)) { httpRequest.Content = new StringContent(contentRequest.Content, contentRequest.Encoding, contentRequest.MediaType); } } var headers = MergeHeaders(request.Headers, authenticator != null ? authenticator.GetHeaders(request) : null); if (headers != null && headers.Count > 0) { foreach (var header in headers) { httpRequest.Headers.Add(header.Key, header.Value); } } return httpRequest; }