Closed ghost closed 9 years ago
Thanks! In this case, vibe.stream.wrapper.StreamOutputRange
would be the best solution here (it does't allocate, but just caches a few bytes internally for performance reasons). I'll tag a new release after a fix gets merged.
Well, I'm out of my depth. I tried
import vibe.stream.wrapper : StreamOutputRange;
auto dst = StreamOutputRange(res.bodyWriter);
...
if (idx > 0) dst.write("\r\n");
dst.formattedWrite("%d\t%s\t%s\t%s\t%s\t%s\t%d\t%d",
...
dst.formattedWrite("\t%s: %s", h.key, sanitizeHeader(h.value));
}
dst.flush();
but I get a bunch of errors from std.format like this:
/usr/include/dmd/phobos/std/format.d(1953,21): Error: struct vibe.stream.wrapper.StreamOutputRange is not copyable because it is annotated with @disable
Sorry, forgot about that - Since formattedWrite
doesn't take the output range by reference for some reason, it needs to be called with a pointer to the range: (&dst).formattedWrite(...)
(StreamOutputRange
is not behaving like a reference type for efficiency reasons, in contrast to some other output ranges, such as Appender
).
Now compiles and runs with StreamOutputRange. Okay? (Sorry for the extraneous white-space changes - I'm quite new to all this.)
The change looks good, thanks. I'll pull and fix the formatting (as well as putting an .editorconfig file into the repository).
Here is a possible workaround for issue #30