I'll try setting the count to 0
, but my attempts to manually set the Transfer-Encoding
were unsuccessful, as all content still came back as a single blob to the client. If I want to replicate a log stream that sends a bit of content over time, can I just schedule write
calls to the stream writer on the EventLoop
? I've tried this but it didn't work, but perhaps the body size is the issue:
let response = Response(body: .init(stream: { writer in
let start = writer.write(.buffer(buffer))
var next = start
for _ in 0..<count {
next = next.flatMap {
request.eventLoop.scheduleTask(in: .milliseconds(500)) {
_ = writer.write(.buffer(buffer))
}.futureResult
}
}
next.flatMap { writer.write(.end) }
}, count: buffer.readableBytes * count))