Skip to content

Commit 9fbcdf8

Browse files
VanHuychemGrusscam
authored andcommitted
Fix synchronous HEAD request (#3188)
When making a HEAD requests the response does not contain a ContentType. The Async version of `Request` already has this check, however the synchronous call fails with a NullReferenceException.
1 parent a11c4a4 commit 9fbcdf8

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public virtual TResponse Request<TResponse>(RequestData requestData)
7272
statusCode = (int) responseMessage.StatusCode;
7373

7474
responseMessage.Headers.TryGetValues("Warning", out warnings);
75-
mimeType = responseMessage.Content.Headers.ContentType.ToString();
75+
mimeType = responseMessage.Content.Headers.ContentType?.MediaType;
7676

7777
if (responseMessage.Content != null)
7878
responseStream = responseMessage.Content.ReadAsStreamAsync().GetAwaiter().GetResult();

0 commit comments

Comments
 (0)