This update brings significant improvements to HTTP engine architecture, a new file server system, and framework enhancements.
HTTP File Server
Introduced the new HttpFileServer system for serving static files efficiently and flexibly:
- Optimized streaming with
Rangeheader support for audio and video - Customizable converters through
HttpFileServerFileConverter - Configurable directory listing
- Automatic content negotiation based on MIME types
var route = HttpFileServer.CreateServingRoute("/static", "./public");
router += route;
// Or with custom configuration
var handler = new HttpFileServerHandler("./public") {
AllowDirectoryListing = true,
// Add custom converters
};
var route = HttpFileServer.CreateServingRoute("/files", handler);The new FileContent class allows returning files with automatic streaming and range request support:
router.SetRoute(RouteMethod.Get, "/download", request => {
return new FileContent("./video.mp4");
});The HttpFileAudioConverter and HttpFileVideoConverter converters provide automatic support for range requests in media files, enabling seeking in audio/video players.
HTTP Engine Improvements
Significant improvements to HTTP engine abstraction:
- Nova interface
HttpServerEngineContext: Abstração completa do ciclo de vida de requisições HTTP HttpServerEngineWebSocket: Interface abstrata para WebSocket em diferentes engines- Mecanismos de event loop: Suporte através de
HttpServerEngineContextEventLoopMecanism - Melhor integração SSL: Classe
ListeningHostSslOptionspara configuração SSL por listening host
var host = new ListeningHost("https://localhost:5000") {
SslOptions = new ListeningHostSslOptions {
Certificate = myCertificate
}
};Logging Improvements
RotatingLogPolicyCompressor: Interface for automatic compression of rotated logsGZipRotatingLogPolicyCompressor: Built-in implementation with GZip compressionPrefixedLogStream: Improvements to prefixed log stream
var rotatingPolicy = new RotatingLogPolicy {
Compressor = new GZipRotatingLogPolicyCompressor()
};HTTP Server Handler Improvements
- Handler execution ordering: Added
Priorityproperty toHttpServerHandlerto control execution order HttpServerHandlerSortingComparer: New comparer for sorting handlers by priority (lower values execute first)HttpServerHandlerRepository: Changed internal storage fromList<T>toSortedSet<T>for automatic priority-based ordering
WebSocket Improvements
- Fix: Corrections to WebSocket connection management
- Improvements to
HttpWebSocketConnectionCollection - Better handling of closed connections
Other Changes
HttpRequestEventSource: Improvements to Server-Sent Events systemCertificateHelper: New helper class for SSL certificate managementHttpRequest.DisconnectToken: Improvements to disconnection detectionHttpServerExecutionResult: New fields for better execution tracking
Breaking Changes
ListeningHost: SSL properties moved toListeningHostSslOptionsHttpServerEngine: New interface with additional abstract methods- Some method signatures in engines have been changed to support the new contexts
Bug Fixes
- Fixed: Simplified connection closed check in HTTP request parsing
- Fixed: HTTP body drainage corrected
- Fixed: Issues with chunked encoding in requests
- Fixed: Better abort handling in HTTP components
- Fixed: Optimized HTTP header parsing and handling