<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 Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc.Filters;

namespace FiltersWebSite
{
    public class TracingResourceFilter : Attribute, IResourceFilter
    {
        public TracingResourceFilter(string name)
        {
            Name = name;
        }
        
        public string Name { get; }

        public void OnResourceExecuted(ResourceExecutedContext context)
        {
            context.HttpContext.Response.Headers.Append(
                "filters", 
                Name + " - OnResourceExecuted");
        }

        public void OnResourceExecuting(ResourceExecutingContext context)
        {
            context.HttpContext.Response.Headers.Append(
                "filters",
                Name + " - OnResourceExecuting");
        }
    }
}<commit_msg>Test: Do not set response headers after the response has started<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 Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc.Filters;

namespace FiltersWebSite
{
    public class TracingResourceFilter : Attribute, IResourceFilter
    {
        public TracingResourceFilter(string name)
        {
            Name = name;
        }
        
        public string Name { get; }

        public void OnResourceExecuted(ResourceExecutedContext context)
        {
            if (!context.HttpContext.Response.HasStarted)
            {
                context.HttpContext.Response.Headers.Append(
                    "filters",
                    Name + " - OnResourceExecuted");
            }
        }

        public void OnResourceExecuting(ResourceExecutingContext context)
        {
            context.HttpContext.Response.Headers.Append(
                "filters",
                Name + " - OnResourceExecuting");
        }
    }
}
{'fraction_non_alphanumeric': 0.07587181903864279, 'fraction_numerical': 0.001885014137606032, 'mean_word_length': 2.0634920634920637, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, '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': '7058221', 'n_tokens_mistral': 517, 'n_tokens_neox': 511, 'n_words': 136}