On 10/14/16 7:49 AM, Grigorii Smorkalov wrote:

I have a lazy input range that produce alot of data (e.g. 1GB). I want to send this data via http without creating temporary array. The most intuitive way would be overloaded method "writeBody" that takes any range of bytes or chars. But there is no such overload. I tried to use StreamOutputRange but it looks wierd:

(scope req) {
	auto writer = StreamOutputRange(req.bodyWriter);
	foreach (c; range) {
		writer.put(c);
	}
}

I am sure that it is not effective and requires internal buffer for whole data.

I did something similar for an input range of JSON objects. I think this
is optimal, even if you may disagree. It must buffer the data somewhere,
because i/o requires a buffer. I don't think the copying is avoidable.

However, support for range output/input would be awesome for vibe.d.
Especially in REST interfaces, putting all data into an array can be
impossible and expensive. This is just a stream, we should be able to
process it one item at a time, and D has extensive support for such a
concept!

-Steve