Vapor: 4.67.0 Release

Release date:
November 3, 2022
Previous version:
4.66.1 (released October 13, 2022)
Magnitude:
211 Diff Delta
Contributors:
3 total committers
Data confidence:
Commits:

Top Contributors in 4.67.0

mcritz
ptoffy
gwynne

Directory Browser for 4.67.0

We haven't yet finished calculating and confirming the files and directories changed in this release. Please check back soon.

Release Notes Published

This patch was authored by @mcritz and released by @0xTim.

This PR wraps Request.Body.drain() as a modern Swift AsyncSequence<ByteBuffer, Error>.

This is useful to stream bytes from request rather than collecting them in memory. Example: A route could handle a multigigbyte file upload like this:

do {
    let nioFileHandle = try NIOFileHandle(path: filePath, mode: .write)
    var offset: Int64 = 0

    for try await bytes in req.body {
        try await req.application.fileio.write(fileHandle: nioFileHandle,
                                               toOffset: offset,
                                               buffer: bytes,
                                               eventLoop: req.eventLoop).get()
        offset += Int64(bytes.readableBytes)
        try nioFileHandle.close()
    }
} catch {
   ...
}