<commit_before>﻿using System;

using Microsoft.AspNetCore.Http;

namespace Wangkanai.Detection.Services
{
    public class HttpContextService : IHttpContextService
    {
        public HttpContext Context { get; }
        public HttpRequest Request => Context.Request;

        public HttpContextService(IHttpContextAccessor accessor)
        {
            if (accessor is null)
                throw new ArgumentNullException(nameof(accessor));
            
            Context = accessor.HttpContext ?? new DefaultHttpContext();
        }
    }
}<commit_msg>HttpContextService will just mock up httpcontext if accessor is null<commit_after>﻿using System;

using Microsoft.AspNetCore.Http;

namespace Wangkanai.Detection.Services
{
    public class HttpContextService : IHttpContextService
    {
        public HttpContext Context { get; }
        public HttpRequest Request => Context.Request;

        public HttpContextService(IHttpContextAccessor accessor) 
            => Context = accessor?.HttpContext 
                         ?? new DefaultHttpContext();

        public static HttpContextService CreateService()
            => new(null!);
    }
}
{'fraction_non_alphanumeric': 0.07087294727744166, 'fraction_numerical': 0.0, 'mean_word_length': 2.6996805111821085, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '4104281', 'n_tokens_mistral': 281, 'n_tokens_neox': 276, 'n_words': 71}