Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
338c6a5
Update ioxide to 0.20.396
MDA2AV Oct 24, 2026
df56643
Fail the ioxide server start when a reactor cannot start
MDA2AV Oct 24, 2026
47d4380
Let websocket connections serialize their writes
MDA2AV Oct 24, 2026
4ed6c18
Share one stream dispatch between the HTTP/2 and HTTP/3 drivers
MDA2AV Oct 24, 2026
1df1def
Skip the debug message for a reactor that could not start either unle…
MDA2AV Oct 24, 2026
4dec969
Rename the engine's IdleTimeoutMs options to ReadTimeoutMs, after ioxide
MDA2AV Oct 26, 2026
8e0dfc1
Update ioxide to 0.26.563, return to the reactor after the handler, a…
MDA2AV Nov 11, 2026
b3c29ce
Websockets serialize their writes by default, and DisableWriteSynchro…
MDA2AV Nov 11, 2026
1042526
Drop the obsolete IdleTimeoutMs aliases of the engine's ReadTimeoutMs…
MDA2AV Nov 11, 2026
8d1bae3
Playground: start the ioxide functional sample
MDA2AV Nov 11, 2026
a60049d
Websockets refuse writes once the handler has ended
MDA2AV Nov 11, 2026
a5d6314
Playground: the ioxide samples set both the read and the flush timeout
MDA2AV Nov 11, 2026
e397479
fix(websockets): Enforce the RFC 6455 framing rules, and keep TryRead…
MDA2AV Nov 14, 2026
28b0cd1
fix(engine): Take the length of a chunk before advancing the reader p…
MDA2AV Nov 14, 2026
5967f5c
test(engine): Read large request bodies through a reader that reuses …
MDA2AV Nov 14, 2026
3ac6b93
chore(engine): Update ioxide to 0.27.637
MDA2AV Nov 16, 2026
60c8278
fix(engine): Log HTTP/2 and HTTP/3 stream faults once, through the se…
MDA2AV Nov 16, 2026
db85b66
fix(engine): HTTP/2 and HTTP/3 uploads without a content-length reach…
MDA2AV Nov 16, 2026
da8db96
Merge main into update-ioxide-0.20.396
MDA2AV Nov 16, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion API/Ioxide/GenHTTP.Api.Ioxide.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

<ItemGroup>

<PackageReference Include="ioxide" Version="0.15.251" />
<PackageReference Include="ioxide" Version="0.27.637" />

</ItemGroup>

Expand Down
21 changes: 21 additions & 0 deletions API/Ioxide/IIoxideFileSink.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
namespace GenHTTP.Api.Ioxide;

/// <summary>
/// A response sink that appends part of a file to the body itself, reading it off the ring straight into the
/// connection's write buffer, after the headers already there.
/// </summary>
/// <remarks>
/// Offered where that buffer is what the response is written to: HTTP/1.1 in cleartext, or with kernel TLS, where
/// the kernel encrypts on send. Content that serves a file checks the sink for this first, and copies the file
/// through a buffer of its own otherwise.
/// </remarks>
public interface IIoxideFileSink
{

/// <summary>
/// Appends <paramref name="length"/> bytes of the file <paramref name="fd"/>, from <paramref name="offset"/>, to the
/// body.
/// </summary>
ValueTask WriteFileAsync(int fd, long offset, long length);

}
56 changes: 44 additions & 12 deletions Engine/Ioxide/EngineOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ public sealed record TcpTransportOptions

public string? CipherList { get; init; }

/// <summary>
/// Hands each TLS connection's sending to the kernel after its handshake (kTLS), so a response is
/// encrypted on send, and a static file served over HTTP/1.1 is read straight into the connection's
/// write buffer.
/// </summary>
/// <remarks>
/// Needs the kernel's <c>tls</c> module: without it the server's start fails, rather than every
/// connection after its handshake.
/// </remarks>
public bool TxKernelTls { get; init; }

public bool RxKernelTls { get; init; }
Expand All @@ -56,33 +65,48 @@ public sealed record TcpTransportOptions
public int RecvQueueEntries { get; init; } = 64;

/// <summary>
/// Close a connection that has neither received nor sent anything for this long. 0 (the
/// default) disables it.
/// Close a connection that has waited this long on its client: a read parked, nothing
/// buffered and nothing being sent. 0 (the default) disables it.
/// </summary>
/// <remarks>
/// The clock only runs while the server waits on the client. Bytes in either direction
/// restart it, a send in flight holds it, and the time a handler spends producing a response
/// does not count - so a slow handler keeps its connection, while an idle keep-alive
/// connection or a silent websocket does not. HTTP/2 is the exception: its frame loop keeps a
/// read parked while handlers work, so a response slower than this, to a client that sends
/// nothing in the meantime, is cut.
///
/// Off by default because this listener also carries upgraded connections, and an idle
/// websocket is a healthy one. ioxide's own default is 60s, which is right for HTTP keep-alive
/// and wrong for a websocket whose ping interval is longer than that - the transport cannot
/// tell the two apart, so the framework does not guess on your behalf.
///
/// Turn it on if you serve no upgrades, or set it comfortably above your websocket ping
/// interval so pings keep the connection marked alive.
/// interval - a ping from either side restarts the clock.
/// </remarks>
public int IdleTimeoutMs { get; init; }
public int ReadTimeoutMs { get; init; }

/// <summary>
/// Close a connection whose response has been outstanding for this long. 0 (the default)
/// disables it.
/// Close a connection whose send has been in flight for this long. 0 (the default) disables it.
/// </summary>
/// <remarks>
/// This is what bounds a client that stops reading: its window shuts, the send never completes,
/// and without a clock the connection is pinned for as long as the peer cares to hold it. TCP
/// will not end it on its own.
/// will not end it on its own, and neither will <see cref="ReadTimeoutMs"/>: a client that
/// keeps sending restarts that clock while its own window stays shut. A websocket written from
/// a background task is the case that needs this one.
///
/// Off by default because it is a deadline for the WHOLE response, not for progress within it,
/// so a large download to a slow client counts against it. Size it against your slowest
/// legitimate response rather than against a stall - for an API that serves small payloads,
/// something like 30s is a straightforward win.
/// Off by default because it is a deadline for a whole flush, not for progress within it, and
/// content that does not flush as it writes goes out as one flush - so a large download to a
/// slow client counts against it. Size it against your slowest legitimate response rather than
/// against a stall - for an API that serves small payloads, something like 30s is a
/// straightforward win.
///
/// The listener also carries it as TCP_USER_TIMEOUT, so the kernel aborts a connection whose
/// client left sent data unacknowledged, or kept its window shut with data waiting, for that long.
/// That covers a client that stopped reading or vanished behind a stream of small flushes, which
/// each complete into the send buffer. A client whose network drops for longer than this, with data
/// in flight, is cut too.
/// </remarks>
public int SendTimeoutMs { get; init; }
}
Expand All @@ -92,7 +116,15 @@ public sealed record QuicTransportOptions
{
public int HandshakeTimeoutMs { get; init; } = 10_000;

public int IdleTimeoutMs { get; init; } = 60_000;
/// <summary>
/// Close a connection whose client has sent nothing for this long. 0 disables it.
/// </summary>
/// <remarks>
/// While a response is still owed, the engine keeps the client answering with keep-alive
/// PINGs, so a slow handler is not timed out - only a client that went quiet with nothing
/// pending is.
/// </remarks>
public int ReadTimeoutMs { get; init; } = 60_000;

public QuicRouting Routing { get; init; } = QuicRouting.Forward;

Expand Down
8 changes: 4 additions & 4 deletions Engine/Ioxide/GenHTTP.Engine.Ioxide.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@

<ProjectReference Include="..\..\Modules\IO\GenHTTP.Modules.IO.csproj" />

<PackageReference Include="ioxide" Version="0.15.251" />
<PackageReference Include="ioxide" Version="0.27.637" />

<PackageReference Include="ioxide.http2" Version="0.15.251" />
<PackageReference Include="ioxide.ngtcp2" Version="0.15.251" />
<PackageReference Include="ioxide.nghttp3" Version="0.15.251" />
<PackageReference Include="ioxide.http2" Version="0.27.637" />
<PackageReference Include="ioxide.ngtcp2" Version="0.27.637" />
<PackageReference Include="ioxide.nghttp3" Version="0.27.637" />

<PackageReference Include="Glyph11" Version="0.4.0" />

Expand Down
38 changes: 17 additions & 21 deletions Engine/Ioxide/Infrastructure/Server.Certificates.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,43 +89,39 @@ private List<CertificateRotation> ResolveRotations(TcpTlsRegistry? started, out
return rotations;
}

// Installs the resolved sets on every reactor, collecting failures rather than stopping half way.
// Installs the resolved sets, collecting failures rather than stopping half way. Every reactor was started with
// each port's one TlsOptions, so its reactors share the port's contexts, and rotating them through one service
// rotates them all: another call per reactor would only build the same set again.
private void Publish(TcpTlsRegistry?[] registries, List<CertificateRotation> rotations)
{
List<Exception>? failures = null;

for (var reactor = 0; reactor < registries.Length; reactor++)
var registry = Array.Find(registries, static r => r is not null);

foreach (var rotation in rotations)
{
if (registries[reactor] is not { } registry)
if (registry is null || !registry.TryFor(rotation.Port, out var service))
{
continue;
}

foreach (var rotation in rotations)
try
{
service.ReplaceCertificates(rotation.Default, rotation.ByHost);
}
catch (Exception e)
{
if (!registry.TryFor(rotation.Port, out var service))
{
continue;
}

try
{
service.ReplaceCertificates(rotation.Default, rotation.ByHost);
}
catch (Exception e)
{
_logger.LogError(e, "Reactor {Reactor} kept the previous certificate on port {Port}", reactor, rotation.Port);

(failures ??= []).Add(e);
}
_logger.LogError(e, "Port {Port} kept its previous certificate", rotation.Port);

(failures ??= []).Add(e);
}
}

if (failures is not null)
{
throw new InvalidOperationException(
$"{failures.Count} of the server's TLS services refused the new certificates and still serve the previous ones; "
+ "the rest were replaced. See the inner exceptions, and the errors logged against each reactor and port.",
$"{failures.Count} of the server's secure ports refused the new certificates and still serve the previous ones; "
+ "the rest were replaced. See the inner exceptions, and the errors logged against each port.",
new AggregateException(failures));
}
}
Expand Down
4 changes: 3 additions & 1 deletion Engine/Ioxide/Infrastructure/Server.Quic.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using GenHTTP.Api.Infrastructure;
using GenHTTP.Engine.Ioxide.Infrastructure.Endpoints;
using GenHTTP.Engine.Ioxide.Protocol.Drivers;

using ioxide;
using ioxide.nghttp3;
Expand Down Expand Up @@ -72,6 +73,7 @@ private ServerConfig WithQuic(ServerConfig serverConfig)
{
QpackDynamicTableCapacity = _engineOptions.Http3.QpackDynamicTableCapacity,
QpackBlockedStreams = _engineOptions.Http3.QpackBlockedStreams,
OnHandlerFault = StreamedDriver.ReportFaults<Nghttp3Request>(Logging, "HTTP/3"),
};

return serverConfig with
Expand All @@ -85,7 +87,7 @@ private ServerConfig WithQuic(ServerConfig serverConfig)
Port = quicEndPoint.Port,
ConnectionFactory = _quicEngine.CreateFactory(),

IdleTimeoutMs = _engineOptions.Quic.IdleTimeoutMs,
ReadTimeoutMs = _engineOptions.Quic.ReadTimeoutMs,
Routing = _engineOptions.Quic.Routing,
PinMigratedPeers = _engineOptions.Quic.PinMigratedPeers,
},
Expand Down
13 changes: 6 additions & 7 deletions Engine/Ioxide/Infrastructure/Server.Tcp.Tls.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace GenHTTP.Engine.Ioxide.Infrastructure;

/// <summary>TLS termination on the TCP transports, in OpenSSL.</summary>
/// <summary>TLS termination on the TCP transports, in BoringSSL.</summary>
public sealed partial class Server
{
// The TLS options for every secure TCP port that can produce a certificate; the rest refuse their handshakes.
Expand Down Expand Up @@ -119,7 +119,7 @@ private void StartTlsServices(Reactor reactor, int index, IReadOnlyList<KeyValue
return byHost.Count > 0 ? byHost : null;
}

// The TLS floor for one endpoint, widening rather than throwing where SslProtocols asks for something OpenSSL cannot express.
// The TLS floor for one endpoint, widening rather than throwing where SslProtocols asks for something BoringSSL cannot express.
private TlsProtocolVersion ResolveMinProtocolVersion(SecureEndPoint endPoint)
{
var protocols = endPoint.SecurityConfiguration.Protocols;
Expand All @@ -130,7 +130,7 @@ private TlsProtocolVersion ResolveMinProtocolVersion(SecureEndPoint endPoint)
if ((protocols & ~(SslProtocols.Tls12 | SslProtocols.Tls13)) != 0)
{
_logger.LogWarning(
"Port {Port} was bound asking for a TLS version below 1.2. This engine terminates TLS in OpenSSL, whose floor is 1.2, "
"Port {Port} was bound asking for a TLS version below 1.2. This engine terminates TLS in BoringSSL, whose floor is 1.2, "
+ "so those versions are not served and never were; the endpoint serves {Served}.",
endPoint.Port, tls13 && !tls12 ? "TLS 1.3" : "TLS 1.2 and above");
}
Expand Down Expand Up @@ -164,7 +164,7 @@ private void WarnAboutValidatorGaps()
if (validator.RevocationCheck != X509RevocationMode.NoCheck)
{
_logger.LogWarning(
"The validator on port {Port} asks for {Mode} revocation checking, which this engine does not perform - neither OpenSSL "
"The validator on port {Port} asks for {Mode} revocation checking, which this engine does not perform - neither BoringSSL "
+ "nor ngtcp2 is given a CRL or an OCSP responder here, so a revoked client certificate is accepted until it expires. "
+ "Use short-lived certificates, or check the peer in ICertificateValidator.Validate against your own source of truth.",
endPoint.Port, validator.RevocationCheck);
Expand All @@ -173,9 +173,8 @@ private void WarnAboutValidatorGaps()
if (endPoint.Protocols.HasFlag(HttpProtocols.Http3))
{
_logger.LogWarning(
"Port {Port} serves HTTP/3 with a certificate validator. Validate runs on the TCP transports, where OpenSSL hands over the "
+ "peer certificate, but NOT over QUIC: ngtcp2 exposes only the peer's subject and common name, so there is no certificate "
+ "to hand it. An HTTP/3 client is admitted on the chain check and RequireCertificate alone. Keep the two transports on "
"Port {Port} serves HTTP/3 with a certificate validator. Validate runs on the TCP transports, but NOT over QUIC: "
+ "an HTTP/3 client is admitted on the chain check and RequireCertificate alone. Keep the two transports on "
+ "separate ports if that difference matters.",
endPoint.Port);
}
Expand Down
12 changes: 10 additions & 2 deletions Engine/Ioxide/Infrastructure/Server.Tcp.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
using GenHTTP.Api.Infrastructure;
using GenHTTP.Engine.Ioxide.Protocol.Drivers;
using ioxide;
using ioxide.http2;

namespace GenHTTP.Engine.Ioxide.Infrastructure;

/// <summary>The TCP listener, which carries HTTP/1.1 and HTTP/2.</summary>
public sealed partial class Server
{
private readonly ushort[] _tcpPorts;


// Shared by every HTTP/2 connection, so the fault hook is built once.
private readonly Http2Options _h2Options;

private Http2Options CreateHttp2Options()
=> new() { OnHandlerFault = StreamedDriver.ReportFaults<Http2Request>(Logging, "HTTP/2") };

// The ports serving HTTP/1.1 or HTTP/2, primary first. Empty on an HTTP/3-only server.
private ushort[] ResolveTcpPorts()
=> _endPoints.Where(e => (e.Protocols & HttpProtocols.Http1AndHttp2) != 0)
Expand All @@ -32,7 +40,7 @@ private ServerConfig WithTcp(ServerConfig serverConfig) => serverConfig with

// Set explicitly, because ioxide defaults both to 60s and this listener carries
// upgraded connections too - inheriting that would start closing idle websockets.
IdleTimeoutMs = _engineOptions.Tcp.IdleTimeoutMs,
ReadTimeoutMs = _engineOptions.Tcp.ReadTimeoutMs,
SendTimeoutMs = _engineOptions.Tcp.SendTimeoutMs,
},
};
Expand Down
Loading
Loading