using System.Net; namespace EmbedIO { /// /// When thrown, breaks the request handling control flow /// and sends a redirection response to the client. /// #pragma warning disable CA1032 // Implement standard exception constructors - they have no meaning here. public class HttpNotAcceptableException : HttpException #pragma warning restore CA1032 { /// /// Initializes a new instance of the class, /// without specifying a value for the response's Vary header. /// public HttpNotAcceptableException() : this(null) { } /// /// Initializes a new instance of the class. /// /// /// A value, or a comma-separated list of values, to set the response's Vary header to. /// Although not specified in RFC7231, /// this may help the client to understand why the request has been rejected. /// If this parameter is or the empty string, the response's Vary header /// is not set. /// public HttpNotAcceptableException(string? vary) : base((int)HttpStatusCode.NotAcceptable) { Vary = string.IsNullOrEmpty(vary) ? null : vary; } /// /// Gets the value, or comma-separated list of values, to be set /// on the response's Vary header. /// /// /// If the empty string has been passed to the /// constructor, the value of this property is . /// public string? Vary { get; } /// public override void PrepareResponse(IHttpContext context) { if (Vary != null) context.Response.Headers.Add(HttpHeaderNames.Vary, Vary); } } }