Skip to content

Commit b8c0db5

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. (cherry picked from commit 9fbcdf8)
1 parent 27b8813 commit b8c0db5

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
@@ -75,7 +75,7 @@ public virtual TResponse Request<TResponse>(RequestData requestData)
7575
statusCode = (int) responseMessage.StatusCode;
7676

7777
responseMessage.Headers.TryGetValues("Warning", out warnings);
78-
mimeType = responseMessage.Content.Headers.ContentType.ToString();
78+
mimeType = responseMessage.Content.Headers.ContentType?.MediaType;
7979

8080
if (responseMessage.Content != null)
8181
responseStream = responseMessage.Content.ReadAsStreamAsync().GetAwaiter().GetResult();

0 commit comments

Comments
 (0)