<commit_before>// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Connections;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Server.IntegrationTesting;
using Microsoft.AspNetCore.Testing;
using Xunit;

namespace Microsoft.AspNetCore.Server.IIS.FunctionalTests
{
    [SkipIfHostableWebCoreNotAvailable]
    [MinimumOSVersion(OperatingSystems.Windows, WindowsVersions.Win8, SkipReason = "https://github.com/aspnet/IISIntegration/issues/866")]
    public class ResponseAbortTests : StrictTestServerTests
    {
        [ConditionalFact]
        public async Task ClosesWithoutSendingAnything()
        {
            using (var testServer = await TestServer.Create(
                ctx => {
                    ctx.Abort();
                    return Task.CompletedTask;
                }, LoggerFactory))
            {
                using (var connection = testServer.CreateConnection())
                {
                    await SendContentLength1Post(connection);
                    await connection.WaitForConnectionClose();
                }
            }
        }

        [ConditionalFact]
        public async Task ClosesAfterDataSent()
        {
            var bodyReceived = CreateTaskCompletionSource();
            using (var testServer = await TestServer.Create(
                async ctx => {
                    await ctx.Response.WriteAsync("Abort");
                    await ctx.Response.Body.FlushAsync();
                    await bodyReceived.Task.DefaultTimeout();
                    ctx.Abort();
                }, LoggerFactory))
            {
                using (var connection = testServer.CreateConnection())
                {
                    await SendContentLength1Post(connection);<commit_msg>Quarantine ClosesAfterDataSent (#31405)<commit_after>// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Connections;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Server.IntegrationTesting;
using Microsoft.AspNetCore.Testing;
using Xunit;

namespace Microsoft.AspNetCore.Server.IIS.FunctionalTests
{
    [SkipIfHostableWebCoreNotAvailable]
    [MinimumOSVersion(OperatingSystems.Windows, WindowsVersions.Win8, SkipReason = "https://github.com/aspnet/IISIntegration/issues/866")]
    public class ResponseAbortTests : StrictTestServerTests
    {
        [ConditionalFact]
        public async Task ClosesWithoutSendingAnything()
        {
            using (var testServer = await TestServer.Create(
                ctx => {
                    ctx.Abort();
                    return Task.CompletedTask;
                }, LoggerFactory))
            {
                using (var connection = testServer.CreateConnection())
                {
                    await SendContentLength1Post(connection);
                    await connection.WaitForConnectionClose();
                }
            }
        }

        [ConditionalFact]
        [QuarantinedTest("https://github.com/dotnet/aspnetcore/issues/31404")]
        public async Task ClosesAfterDataSent()
        {
            var bodyReceived = CreateTaskCompletionSource();
            using (var testServer = await TestServer.Create(
                async ctx => {
                    await ctx.Response.WriteAsync("Abort");
                    await ctx.Response.Body.FlushAsync();
                    await bodyReceived.Task.DefaultTimeout();
                    ctx.Abort();
                }, LoggerFactory))
            {
                using (var connection = testServer.CreateConnection())
                {
                    await SendContentLength1Post(connection);
{'fraction_non_alphanumeric': 0.08276729559748428, 'fraction_numerical': 0.006540880503144654, 'mean_word_length': 2.032799389778795, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 3, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4820472', 'n_tokens_mistral': 960, 'n_tokens_neox': 936, 'n_words': 204}