Repository navigation
v1.7
This release introduces custom route matching, the HTTP QUERY method, atomic request-context values, a safer default request size limit, and a hardened Cadente HTTP/1.1 parser. It also discontinues three extension packages.
Packages in this release: Sisk.HttpServer 1.7.0, Sisk.Cadente 1.7.0, Sisk.Cadente.CoreEngine 1.7.0, Sisk.IniConfiguration 1.7.0 and Sisk.IniConfiguration.Core 1.7.0. Sisk.Documenting, Sisk.Documenting.Html and Sisk.Monitoring ship as 1.7.0-rc3, and Sisk.ModelContextProtocol ships as 1.7.0-rc1.
Breaking changes
-
Breaking:
Route.UseRegexis now read-only and marked[Obsolete]. It returnstrueonly when the route is aRegexRoute. Code that setUseRegex = trueon aRouteno longer compiles, and binaries compiled against earlier versions fail withMissingMethodExceptionwhen they call the removed setter. Create aRegexRouteinstead. TheRouteAttribute.UseRegexproperty and the[RegexRoute]attribute keep working.// before router.Map(new Route(RouteMethod.Get, @"^/items/(?<id>\d+)$", action) { UseRegex = true }); // after router.Map(new RegexRoute(RouteMethod.Get, @"^/items/(?<id>\d+)$", action));
-
Breaking: the default value of
HttpServerConfiguration.MaximumContentLengthchanged from0(unlimited) to 100 MB. The limit is enforced onHttpRequest.RawBody, on the stream returned byHttpRequest.GetRequestStream(), and on the maximum WebSocket message size. Requests that declare aContent-Lengthabove the limit receive413 Content Too Large. Chunked or streamed bodies that exceed the limit throwInsufficientMemoryExceptionwhile being read, which the server reports as500 Internal Server Errorunless the application handles it. Set the property to0to restore the previous unlimited behavior.using var app = HttpServer.CreateBuilder() .UseConfiguration(config => config.MaximumContentLength = 0) .Build();
Applications configured through
UsePortableConfiguration(...)with a JSON file are not affected when theServersection is present: the parser always assignsServer.MaximumContentLength, which defaults to0when the property is omitted. -
Breaking:
Routernow throwsArgumentExceptionwhen the server starts if two or more routes share the sameName. The check runs together with the existing route collision check and is controlled byRouter.CheckForRouteCollisions, which is enabled by default. Applications that registered routes with duplicate names must rename them or disable the check. -
Breaking: static routes are always evaluated before dynamic routes (
RegexRoute,PrefixRouteand customRoutesubclasses), regardless of the order in which they were registered. In earlier versions a regular expression route registered first could shadow a static route registered later. Applications that relied on registration order to give a dynamic route precedence over a static route must adjust their patterns. -
Breaking:
HttpFileServer.CreateServingRoute(...)now returns aPrefixRouteinstead of aRegexRoute, which also applies to routes registered throughRouter.MapFileSystem(...). File server routes no longer participate inHttpServerConfiguration.ForceTrailingSlashrewrites. -
Breaking:
RouteMethod.Anynow includes the newRouteMethod.Queryflag, so routes mapped withAnyalso answerQUERYrequests. BecauseAnyis a constant, its numeric value changed from446to958; code that persisted or compared the raw value must be recompiled. -
Breaking: CORS preflight handling now respects
Route.UseCors. When the matched route hasUseCors = false, the automaticOPTIONSresponse no longer carries CORS headers. Routes explicitly mapped withRouteMethod.Optionstake precedence over the automatic preflight response.
Custom route matching
Route.Match(string requestPath, Router router) is now virtual and returns a RouteMatch object with the match result and the extracted parameters. Subclasses can override it to implement any matching strategy. RegexRoute and the new PrefixRoute are built on this mechanism.
public sealed class ExtensionRoute : Route
{
private readonly string extension;
public ExtensionRoute(string extension, RouteAction action)
: base(RouteMethod.Get, "/", action)
{
this.extension = extension;
}
public override bool IsStatic => false;
public override RouteMatch Match(string requestPath, Router router)
{
return requestPath.EndsWith(extension, StringComparison.OrdinalIgnoreCase)
? new RouteMatch(true, null)
: RouteMatch.NotMatched;
}
}
router.Map(new ExtensionRoute(".md", request => new HttpResponse("markdown")));- Added
PrefixRoute, which matches every request path that starts with the configured prefix. - Added
RouteMatchwithSuccess,Parametersand the staticRouteMatch.NotMatchedinstance. - Added the
protected virtualmethodRoute.OnPathModified()and thevirtualpropertiesRoute.IsStaticandRoute.AllowRewrites, so subclasses control collision checks, ordering and trailing-slash rewrites. - Added a parameterless constructor to
RegexRoute. - Changed the route collision check to compare only static routes, which removes false collision errors between regular expression routes and static routes.
HTTP QUERY method
Added support for the HTTP QUERY method in Sisk.HttpServer and Sisk.Cadente.
router.MapQuery("/search", request =>
{
string filter = request.Body;
return new HttpResponse(filter)
{
Headers = new() { AcceptQuery = "application/json" }
};
});- Added
RouteMethod.Query,Router.MapQuery(...),Route.Query(...)and the[RouteQuery]attribute. - Added
HttpHeaderCollection.AcceptQueryandHttpKnownHeaderNames.AcceptQuery.
Request context
-
Added
HttpContext.Interlocked, anHttpContextInterlockedinstance withAdd,Exchange,CompareExchangeandInspectmethods for atomic numeric values stored in the request context. It is useful for counters shared between request handlers and the route action.public override HttpResponse? Execute(HttpRequest request, HttpContext context) { context.Interlocked.Add("attempts", 1); return null; }
-
HttpContextnow implementsIDisposableand is disposed by the server at the end of the request. -
Fixed an issue where
HttpListenerAbstractEngine.ContextAbortedTokenthrewHttpEngineException; it now returnsCancellationToken.None.
Server and request pipeline
- Changed the HttpListener engine to dispatch each accepted context to the thread pool. Previously a request could be handled inline on the accept callback and wait for the next incoming request before completing.
- Fixed an issue where request bodies were buffered in a
MemoryStreampreallocated with the declaredContent-Length, which allowed a client to force large allocations before the body was read. - Fixed an issue where an exception thrown by
ForwardingResolver.OnResolveClientAddresswas raised a second time while writing the access log, which terminated the process with the default engine and left the server locked whenAsyncRequestProcessingwasfalse. - Changed
HttpServerHandlerexception handling at the end of a request: exceptions thrown byOnHttpRequestClose,OnExceptionor by log formatting are written toErrorsLogsStreamand never escape the engine callback. WhenThrowExceptionsis enabled, handler exceptions raised by server lifecycle events are wrapped in anInvalidOperationExceptionwith the original exception asInnerException. - Fixed an issue where
HttpRequestEventSourceflushed the output stream outside the serialized send section, which could interleave with concurrent writes. - Fixed an issue where
+characters in request paths were decoded as spaces byHttpFileServerHandler. - Added
.toon,.xcssand.slnxto the plain text file extensions recognized by the file server.
CORS
- Fixed an issue where preflight requests ignored
Route.UseCorsand explicitOPTIONSroutes. - Added the
Vary: Originresponse header whenAllowOriginis set to the automatic value or whenAllowOriginscontains a list of origins.
Logging
- Added the
%{$name}access log format term, which prints the value stored undernameinHttpContext.RequestBag. - Changed the
%riaccess log term to use the client address resolved at the start of the request instead of invoking theForwardingResolveragain. - Added the helper methods
LogStream.SafeWriteToFile(...)andLogStream.SafeAppendToFile(...), with synchronous and asynchronous overloads for text and line arrays. They create missing directories, serialize concurrent writes to the same file and returnfalseinstead of throwing on I/O failures. - Added the helper methods
PathHelper.EnsureDirectoryExistance(...)andPathHelper.EnsureFileDirectoryExistance(...).
Cadente
Sisk.Cadente and Sisk.Cadente.CoreEngine target net9.0 and net10.0.
- Added support for pipelined keep-alive requests with buffered connection I/O.
- Added
HttpHostContext.HttpResponse.WriteInlineContent(ReadOnlySpan<byte>)andWriteInlineContentAsync(ReadOnlyMemory<byte>, CancellationToken). - Changed
HttpServer.ListeningPrefixesto report thehttpsscheme for listening hosts configured with SSL. - Fixed a security issue where request targets containing bytes outside
%x21-7Ewere accepted. A target such as/admin\x80xwas routed to/admin, and a line feed inside the target forged extra lines in the error log. These requests are now rejected. - Fixed an issue where request methods that are not valid HTTP tokens reached the core and produced a
500response throughFormatException. They are now rejected by the parser. - Fixed an issue where a request whose header block exceeded the 8 KB read buffer closed the connection silently. Cadente now answers
431 Request Header Fields Too LargewithConnection: close. - Fixed an issue where requests with
Transfer-Encodingvalues other than a singlechunkedtoken, or with conflictingContent-Lengthheaders, were accepted. - Fixed an issue where the request body byte counter overflowed for bodies larger than 2 GB, and where draining a large body could consume bytes of the next pipelined request (#51).
Packaging
Sisk.HttpServertargetsnet8.0,net9.0andnet10.0.Sisk.CadenteandSisk.Cadente.CoreEnginenow publish portable.snupkgsymbol packages instead of embedding debug symbols in the assemblies.Sisk.HttpServerkeeps embedded symbols.
Extensions
Discontinued packages
The following packages are no longer maintained. Their latest versions are marked as deprecated on NuGet with no replacement, and their source code is kept in the repository for historical reference only.
- Removed
Sisk.BasicAuthfrom the supported packages. TheBasicAuthenticateRequestHandlershipped since 1.5.2 does not decode the Base64 credentials sent by standard HTTP clients, so authenticated requests are rejected with400. Applications should implement Basic authentication with a customIRequestHandler. - Removed
Sisk.SslProxyfrom the supported packages. It no longer compiles against the currentSisk.CadenteAPI. Use the native TLS support ofSisk.Cadenteinstead. - Removed
Sisk.ServiceProviderfrom the supported packages. It targetsnet6.0andnet7.0only and has not been updated since 2024. Its configuration features are available throughHttpServer.CreateBuilder()andUsePortableConfiguration(...)inSisk.HttpServer.
Sisk.Documenting and Sisk.Documenting.Html (1.7.0-rc3)
- Added parameter examples to documented endpoints.
- Added
LlmsApiExporter.FooterTextto append custom text to the generatedllms.txtoutput. - Changed the HTML documentation layout with endpoint navigation, a search dialog and collapsible content.
- Fixed an issue where endpoint and group element IDs could be empty, collide with each other or be invalid CSS selectors, which aborted the page script with a
SyntaxError. Endpoint IDs are now derived from the method and route path. Anchors produced by the previous ID scheme no longer resolve. - Fixed an issue where endpoints with the same name but different paths were collapsed into a single entry.
- Fixed an issue where endpoint names, paths and groups were written to the search results without HTML escaping.
- Fixed an issue where Markdown descriptions were not rendered as CommonMark.
Sisk.Monitoring (1.7.0-rc3)
- Added HTTP traffic, latency, route and exception telemetry to the dashboard.
- Reduced the cost of
Counter.IncrementandMeter.Increment.Counterkept one entry per increment and scanned the whole list on every call, andMeterrebuilt an array with every bucket key on every call, so both became slower as data accumulated. Increments are now amortized O(1) andMeter.Incrementno longer allocates.
Sisk.ModelContextProtocol (1.7.0-rc1)
- Added skills support to
McpProvider. - Updated the streamable HTTP transport to the current Model Context Protocol revision.
Sisk.IniConfiguration (1.7.0)
- Updated the package version to match the core release. There are no code changes. Because of the new core default, omitting
Server.MaximumContentLengthin the INI file now results in a 100 MB limit.