in Sources/NIOWritePartialPCAPDemo/main.swift [39:51]
func channelRead(context: ChannelHandlerContext, data: NIOAny) {
if case .head(let header) = self.unwrapInboundIn(data) {
if header.status == .preconditionFailed {
// For the sake of a repeatable demo, let's assume that seeing a preconditionFailed
// status is the sign that the issue you're looking to diagnose has happened.
// Obviously in real usage there will be a hypothesis you're trying to test
// which should give the trigger condition.
let capturedFragments = self.pcapRingBuffer.emitPCAP()
self.capturedFragmentSink(captured: capturedFragments)
}
}
context.fireChannelRead(data)
}