@@ -23,10 +23,12 @@ public class RequestData
2323 private static readonly string MimeType = "application/vnd.elasticsearch+json; compatible-with="
2424 + ClientVersionInfo . LowLevelClientVersionInfo . Version . Major ;
2525
26+ private static readonly string TrimmedMimeType = "application/vnd.elasticsearch+json;compatible-with="
27+ + ClientVersionInfo . LowLevelClientVersionInfo . Version . Major ;
28+
2629 public static readonly string DefaultJsonMimeType =
2730 ClientVersionInfo . LowLevelClientVersionInfo . Version . Major >= 8 ? MimeType : MimeTypeOld ;
2831
29-
3032 private readonly string _path ;
3133 private Node _node ;
3234 private Uri _requestUri ;
@@ -209,13 +211,16 @@ public static bool ValidResponseContentType(string acceptMimeType, string respon
209211
210212 //vendored check
211213 if ( acceptMimeType == MimeType )
214+ {
212215 // we check both vendored and nonvendored since on 7.x the response does not return a
213- // vendored Content-Type header on the response
216+ // vendored Content-Type header on the response.
214217 return
215- responseMimeType == MimeType
216- || responseMimeType == MimeTypeOld
218+ responseMimeType . Equals ( MimeType , StringComparison . Ordinal )
219+ || responseMimeType . Equals ( TrimmedMimeType , StringComparison . Ordinal ) // Required for .NET FX as the whitespace in the response Content-Type header is stripped
220+ || responseMimeType . Equals ( MimeTypeOld , StringComparison . Ordinal )
217221 || responseMimeType . StartsWith ( MimeTypeOld , StringComparison . OrdinalIgnoreCase )
218222 || responseMimeType . StartsWith ( MimeType , StringComparison . OrdinalIgnoreCase ) ;
223+ }
219224
220225 return responseMimeType . StartsWith ( acceptMimeType , StringComparison . OrdinalIgnoreCase ) ;
221226 }
0 commit comments