Skip to content

v1.6.0

Latest

Choose a tag to compare

@CypherPotato CypherPotato released this 16 Dec 19:27
· 10 commits to main since this release

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 Range header 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 ListeningHostSslOptions para 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 logs
  • GZipRotatingLogPolicyCompressor: Built-in implementation with GZip compression
  • PrefixedLogStream: Improvements to prefixed log stream
var rotatingPolicy = new RotatingLogPolicy {
    Compressor = new GZipRotatingLogPolicyCompressor()
};

HTTP Server Handler Improvements

  • Handler execution ordering: Added Priority property to HttpServerHandler to control execution order
  • HttpServerHandlerSortingComparer: New comparer for sorting handlers by priority (lower values execute first)
  • HttpServerHandlerRepository: Changed internal storage from List<T> to SortedSet<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 system
  • CertificateHelper: New helper class for SSL certificate management
  • HttpRequest.DisconnectToken: Improvements to disconnection detection
  • HttpServerExecutionResult: New fields for better execution tracking

Breaking Changes

  • ListeningHost: SSL properties moved to ListeningHostSslOptions
  • HttpServerEngine: 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