protected override async Task CheckHealthInternalAsync()

in src/Diagnostics.HealthChecks/Internal/HttpEndpointHealthCheck.cs [31:68]


		protected override async Task<HealthCheckResult> CheckHealthInternalAsync(HealthCheckContext context, CancellationToken token)
		{
			string checkName = context.Registration.Name;

			HttpClient httpClient = m_httpClientFactory.CreateClient(HttpClientLogicalName);
			HttpResponseMessage? response = await httpClient.SendAsync(CloneRequestMessage(Parameters.RequestMessage), token).ConfigureAwait(false);

			HealthStatus healthStatus = HealthStatus.Unhealthy;
			string description = string.Empty;

			if (response != null)
			{
				if (response.StatusCode == Parameters.ExpectedStatus)
				{
					healthStatus = HealthStatus.Healthy;
				}
				else
				{
					Logger.LogWarning(Tag.Create(), "'{0}' is unhealthy, expected request result {1}, actual {2}",
						checkName, Parameters.ExpectedStatus, response.StatusCode);

					// attach response to description only if check is not healthy to improve performance
					description = await response.Content.ReadAsStringAsync();
				}
			}

			HealthCheckResult result = new(healthStatus, description, data: Parameters.ReportData);

			if (Parameters.AdditionalCheck != null && response != null)
			{
				Logger.LogInformation(Tag.Create(), "'{0}' check result will be overridden by {1}",
					checkName, nameof(HttpHealthCheckParameters.AdditionalCheck));

				result = await Parameters.AdditionalCheck(response, result).ConfigureAwait(false);
			}

			return result;
		}