Skip to content

Commit

Permalink
HttpClientConnection (alternative for the builtin) had a NRE causing …
Browse files Browse the repository at this point in the history
…it to misbehave
  • Loading branch information
Mpdreamz committed Sep 16, 2014
1 parent ed92427 commit c67c213
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,6 @@ public async Task<ElasticsearchResponse<Stream>> DoRequest(HttpMethod method, Ur
else if (!string.IsNullOrWhiteSpace(DefaultContentType))
request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(DefaultContentType));

if (!string.IsNullOrWhiteSpace(DefaultContentType))
request.Content.Headers.ContentType = new MediaTypeHeaderValue(DefaultContentType);

if (!string.IsNullOrEmpty(uri.UserInfo))
{
Expand All @@ -137,6 +135,8 @@ public async Task<ElasticsearchResponse<Stream>> DoRequest(HttpMethod method, Ur
if (method != HttpMethod.Get && method != HttpMethod.Head && data != null && data.Length > 0)
{
request.Content = new ByteArrayContent(data);
if (!string.IsNullOrWhiteSpace(DefaultContentType) && request.Content != null && request.Content.Headers != null)
request.Content.Headers.ContentType = new MediaTypeHeaderValue(DefaultContentType);
}

var response = await Client.SendAsync(request, HttpCompletionOption.ResponseHeadersRead);
Expand Down

0 comments on commit c67c213

Please sign in to comment.