diff --git a/src/Tgstation.Server.Host/Utils/ApiHeadersProvider.cs b/src/Tgstation.Server.Host/Utils/ApiHeadersProvider.cs index 95190dc500..1805d337c1 100644 --- a/src/Tgstation.Server.Host/Utils/ApiHeadersProvider.cs +++ b/src/Tgstation.Server.Host/Utils/ApiHeadersProvider.cs @@ -4,20 +4,18 @@ using Microsoft.AspNetCore.Http; using Tgstation.Server.Api; -#nullable disable - namespace Tgstation.Server.Host.Utils { /// sealed class ApiHeadersProvider : IApiHeadersProvider { /// - public ApiHeaders ApiHeaders => attemptedApiHeadersCreation + public ApiHeaders? ApiHeaders => attemptedApiHeadersCreation ? apiHeaders : CreateApiHeaders(false); /// - public HeadersException HeadersException { get; private set; } + public HeadersException? HeadersException { get; private set; } /// /// The for the . @@ -27,7 +25,7 @@ namespace Tgstation.Server.Host.Utils /// /// Backing field for . /// - ApiHeaders apiHeaders; + ApiHeaders? apiHeaders; /// /// If populating was previously attempted. @@ -44,14 +42,14 @@ namespace Tgstation.Server.Host.Utils } /// - public ApiHeaders CreateAuthlessHeaders() => CreateApiHeaders(true); + public ApiHeaders CreateAuthlessHeaders() => CreateApiHeaders(true)!; /// /// Attempt to parse from the , optionally populating the properties. /// /// If the error should be ignored and / should not be populated. /// A newly parsed or if was set and the parse failed. - ApiHeaders CreateApiHeaders(bool authless) + ApiHeaders? CreateApiHeaders(bool authless) { if (httpContextAccessor.HttpContext == null) throw new InvalidOperationException("httpContextAccessor has no HttpContext!");