Files
swift-nio-http2/Sources/NIOHTTP2/NIOHTTP2FrameDelegate.swift
George Barnett 5e9e99ec96 Add a frame delegate (#522)
Motivation:

Frames written from a child channel may not be written immediately by
the connection channel. For example, a DATA frame written on a stream
may be larger than the max frame size imposed on the connection and so
the connection channel will have to slice it into multiple frames. Or
the connection may not be writable and may delay the transmission of the
frame. This behaviour isn't currently observable but is useful to know
about.

Modifications:

- Add a frame delegate which is notified when certain frames are written
by the connection channel.

Result:

Users can observer when headers and data frames are written into the
connection channel.
2025-07-18 15:30:36 +01:00

31 lines
1.1 KiB
Swift

//===----------------------------------------------------------------------===//
//
// This source file is part of the SwiftNIO open source project
//
// Copyright (c) 2025 Apple Inc. and the SwiftNIO project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of SwiftNIO project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
import NIOCore
import NIOHPACK
/// A delegate which can be used with the ``NIOHTTP2Handler`` which is notified
/// when various frame types are written into the connection channel.
///
/// This delegate, when used by the ``NIOHTTP2Handler`` will be called on the event
/// loop associated with the channel that the handler is a part of. As such you should
/// avoid doing expensive or blocking work in this delegate.
public protocol NIOHTTP2FrameDelegate {
/// Called when a frame is written by the connection channel.
///
/// - Parameters:
/// - frame: The frame to write.
func wroteFrame(_ frame: HTTP2Frame)
}