Ah, I see what you mean. Unfortunately Ring doesn't currently support HTTP trailers, and neither does the latest Servlet spec, so we can't fall back to that.
I don't think you'll be able to add trailers through the OutputStream either, because they need to come after the final chunk. You might be able to do it if you can set a content-length header, but the HTTP server behind the adapter might stop those sort of shenanigans.
You could create a custom Ring adapter with support for a :trailers key, perhaps using a delay that would be forced when after the output stream is closed. This would tie you to a specific adapter (such as Jetty), but I don't think it would be too onerous to adapt ring.adapter.jetty to that purpose.
Alternatively, you could encode the error in the output you're producing. For example, if you're streaming a JSON array, you could wrap it in an object:
{
"results": [
...streaming...
],
"status": {"type": "error"}
}
That's the most straightforward solution I can think of.
- James