From 3e29c8ca528ba22688ef62e4963a642da9ffbd53 Mon Sep 17 00:00:00 2001 From: Aryan Shah Date: Fri, 16 Oct 2026 11:07:10 +0100 Subject: [PATCH] Default `trailer` to nil in the concrete `sendAndFinish` ### Motivation #136 added a concrete `sendAndFinish(_:buffer:trailer:)` that writes the head, body and end in a single write. We should add a default value to the `trailer` argument so that callers who omit the `trailer` argument can use this optimised implementation instead of the default implementation provided by `HTTPAPIs`. ### Modifications - Default `trailer` to `nil` on the concrete `sendAndFinish`. ### Result Calls without `trailer` get the single-write path. --- Sources/NIOHTTPServer/NIOHTTPServerResponseSender.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/NIOHTTPServer/NIOHTTPServerResponseSender.swift b/Sources/NIOHTTPServer/NIOHTTPServerResponseSender.swift index 35f563e..523dea5 100644 --- a/Sources/NIOHTTPServer/NIOHTTPServerResponseSender.swift +++ b/Sources/NIOHTTPServer/NIOHTTPServerResponseSender.swift @@ -70,7 +70,7 @@ extension NIOHTTPServer { public consuming func sendAndFinish( _ response: HTTPResponse, buffer: inout Buffer, - trailer: HTTPFields? + trailer: HTTPFields? = nil ) async throws where Buffer: RangeReplaceableContainer, Buffer.Element == UInt8, Buffer: ~Copyable { precondition(response.status.kind != .informational) if buffer.isEmpty {