# Streaming multiple payloads through a response

**URL:** <https://forums.swift.org/t/streaming-multiple-payloads-through-a-response/35240>\
**Category:** Vapor\
**Created:** [April 10, 2020, 3:02am UTC](https://forums.swift.org/t/streaming-multiple-payloads-through-a-response/35240 "2020-04-10T03:02:57Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![Jon\_Shier](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/jon_shier/32/921_2.png) [@Jon\_Shier](https://forums.swift.org/u/Jon_Shier)\
**Post date:** [April 13, 2020, 7:12pm UTC](https://forums.swift.org/t/streaming-multiple-payloads-through-a-response/35240/4 "2020-04-13T19:12:28Z")

</div>

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:

```swift
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))

```

---

_[View the full topic](https://forums.swift.org/t/streaming-multiple-payloads-through-a-response/35240)._
