@@ -23,10 +23,12 @@ public class RequestData
23
23
private static readonly string MimeType = "application/vnd.elasticsearch+json; compatible-with="
24
24
+ ClientVersionInfo . LowLevelClientVersionInfo . Version . Major ;
25
25
26
+ private static readonly string TrimmedMimeType = "application/vnd.elasticsearch+json;compatible-with="
27
+ + ClientVersionInfo . LowLevelClientVersionInfo . Version . Major ;
28
+
26
29
public static readonly string DefaultJsonMimeType =
27
30
ClientVersionInfo . LowLevelClientVersionInfo . Version . Major >= 8 ? MimeType : MimeTypeOld ;
28
31
29
-
30
32
private readonly string _path ;
31
33
private Node _node ;
32
34
private Uri _requestUri ;
@@ -209,13 +211,16 @@ public static bool ValidResponseContentType(string acceptMimeType, string respon
209
211
210
212
//vendored check
211
213
if ( acceptMimeType == MimeType )
214
+ {
212
215
// 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.
214
217
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 )
217
221
|| responseMimeType . StartsWith ( MimeTypeOld , StringComparison . OrdinalIgnoreCase )
218
222
|| responseMimeType . StartsWith ( MimeType , StringComparison . OrdinalIgnoreCase ) ;
223
+ }
219
224
220
225
return responseMimeType . StartsWith ( acceptMimeType , StringComparison . OrdinalIgnoreCase ) ;
221
226
}
0 commit comments