using System.Globalization; using System.Net; using Umbraco.Cms.Core.Models; using Umbraco.Cms.Core.Models.PublishedContent; using Umbraco.Extensions; namespace Umbraco.Cms.Core.Routing; /// /// Used by to route inbound requests to Umbraco content /// public interface IPublishedRequestBuilder { /// /// Gets the cleaned up inbound Uri used for routing. /// /// The cleaned up Uri has no virtual directory, no trailing slash, no .aspx extension, etc. Uri Uri { get; } /// /// Gets the URI decoded absolute path of the /// string AbsolutePathDecoded { get; } /// /// Gets the assigned (if any) /// DomainAndUri? Domain { get; } /// /// Gets the assigned (if any) /// string? Culture { get; } /// /// Gets a value indicating whether the current published content has been obtained /// from the initial published content following internal redirections exclusively. /// /// /// Used by PublishedContentRequestEngine.FindTemplate() to figure out whether to /// apply the internal redirect or not, when content is not the initial content. /// bool IsInternalRedirect { get; } /// /// Gets the content request http response status code. /// int? ResponseStatusCode { get; } /// /// Gets the current assigned (if any) /// IPublishedContent? PublishedContent { get; } /// /// Gets the template assigned to the request (if any) /// ITemplate? Template { get; } /// /// Builds the /// IPublishedRequest Build(); /// /// Sets the domain for the request which also sets the culture /// IPublishedRequestBuilder SetDomain(DomainAndUri domain); /// /// Sets the culture for the request /// IPublishedRequestBuilder SetCulture(string? culture); /// /// Sets the found for the request /// /// Setting the content clears the template and redirect IPublishedRequestBuilder SetPublishedContent(IPublishedContent? content); /// /// Sets the requested content, following an internal redirect. /// /// The requested content. /// Since this sets the content, it will clear the template IPublishedRequestBuilder SetInternalRedirect(IPublishedContent content); /// /// Tries to set the template to use to display the requested content. /// /// The alias of the template. /// A value indicating whether a valid template with the specified alias was found. /// /// Successfully setting the template does refresh RenderingEngine. /// If setting the template fails, then the previous template (if any) remains in place. /// bool TrySetTemplate(string alias); /// /// Sets the template to use to display the requested content. /// /// The template. /// Setting the template does refresh RenderingEngine. IPublishedRequestBuilder SetTemplate(ITemplate? template); /// /// Indicates that the content request should trigger a permanent redirect (301). /// /// The url to redirect to. /// /// Does not actually perform a redirect, only registers that the response should /// redirect. Redirect will or will not take place in due time. /// IPublishedRequestBuilder SetRedirectPermanent(string url); /// /// Indicates that the content request should trigger a redirect, with a specified status code. /// /// The url to redirect to. /// The status code (300-308). /// /// Does not actually perform a redirect, only registers that the response should /// redirect. Redirect will or will not take place in due time. /// IPublishedRequestBuilder SetRedirect(string url, int status = (int)HttpStatusCode.Redirect); /// /// Sets the http response status code, along with an optional associated description. /// /// The http status code. /// /// Does not actually set the http response status code and description, only registers that /// the response should use the specified code and description. The code and description will or will /// not be used, in due time. /// IPublishedRequestBuilder SetResponseStatus(int code); /// /// Sets the no-cache value to the Cache-Control header /// /// True to set the header, false to not set it IPublishedRequestBuilder SetNoCacheHeader(bool setHeader); /// /// Sets a list of Extensions to append to the Response.Cache object. /// IPublishedRequestBuilder SetCacheExtensions(IEnumerable cacheExtensions); /// /// Sets a dictionary of Headers to append to the Response object. /// IPublishedRequestBuilder SetHeaders(IReadOnlyDictionary headers); /// /// Can be called to configure the result to ignore URL collisions /// /// /// /// This is an uncommon API used for edge cases with complex routing and would be used /// by developers to configure the request to disable collision checks in . /// /// /// This flag is based on previous Umbraco versions but it is not clear how this flag can be set by developers /// since /// collission checking only occurs in the back office which is launched by /// /// for which events do not execute. /// /// /// More can be read about this setting here: https://github.com/umbraco/Umbraco-CMS/pull/2148, /// https://issues.umbraco.org/issue/U4-10345 /// but it's still unclear how this was used. /// /// void IgnorePublishedContentCollisions(); }