protected static bool MayHaveBody()

in src/Elastic.Transport/Responses/ResponseFactory.cs [111:134]


	protected static bool MayHaveBody(int? statusCode, HttpMethod httpMethod, long contentLength) =>
		contentLength != 0 && (!statusCode.HasValue || statusCode.Value != 204 && httpMethod != HttpMethod.HEAD);

	internal static bool ValidateResponseContentType(string accept, string responseContentType)
	{
		if (string.IsNullOrEmpty(responseContentType)) return false;

		if (accept == responseContentType)
			return true;

		// TODO - Performance: Review options to avoid the replace here and compare more efficiently.
		var trimmedAccept = accept.Replace(" ", "");
		var normalizedResponseContentType = responseContentType.Replace(" ", "");

		return normalizedResponseContentType.Equals(trimmedAccept, StringComparison.OrdinalIgnoreCase)
			|| normalizedResponseContentType.StartsWith(trimmedAccept, StringComparison.OrdinalIgnoreCase)

			// ES specific fallback required because:
			// - 404 responses from ES8 don't include the vendored header
			// - ES8 EQL responses don't include vendored type

			|| trimmedAccept.Contains("application/vnd.elasticsearch+json")
			&& normalizedResponseContentType.StartsWith(BoundConfiguration.DefaultContentType, StringComparison.OrdinalIgnoreCase);
	}