Skip to content

Commit c6c1bcd

Browse files
committed
Core CLR http connection implementation is now more defensive in how it queries the header collection
1 parent acf095c commit c6c1bcd

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/Elasticsearch.Net/Connection/HttpConnection-CoreFx.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#if DOTNETCORE
22
using System;
33
using System.Collections.Concurrent;
4+
using System.Collections.Generic;
45
using System.IO;
56
using System.IO.Compression;
67
using System.Net;
@@ -92,7 +93,9 @@ public virtual async Task<ElasticsearchResponse<TReturn>> RequestAsync<TReturn>(
9293
var response = await client.SendAsync(requestMessage, cancellationToken).ConfigureAwait(false);
9394
requestData.MadeItToResponse = true;
9495
builder.StatusCode = (int)response.StatusCode;
95-
builder.DeprecationWarnings = response.Headers.GetValues("Warning");
96+
IEnumerable<string> warnings;
97+
if (response.Headers.TryGetValues("Warning", out warnings))
98+
builder.DeprecationWarnings = warnings;
9699

97100
if (response.Content != null)
98101
builder.Stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false);

0 commit comments

Comments
 (0)