Thank you for your answer, Nelson.

I was near to your solution. Thank you for reminding me to flush the writer.

Now I detected the real problem in my application: I did not use the jetty 
adapter but the http-kit <http://www.http-kit.org> server. http-kit buffers 
whole response body from InputStream before sending to client 
<https://github.com/http-kit/http-kit/issues/90>.

I switched to jetty, added the flush and everything works like a charm.

Am Montag, 20. April 2015 21:49:42 UTC+2 schrieb Nelson Morris:
>
> The `clojure.data.xml/emit` function will stream xml to a Writer. To hook 
> it up to `piped-input-stream` requires a little bit of book keeping work. 
> `piped-input-stream` provides an OutputStream and we need to convert that 
> to a Writer.  Luckily `clojure.java.io/writer` 
> <http://clojure.java.io/writer> can handle that for us.  Additionally, 
> we'll need to `flush` at the end in order to make sure this intermediate 
> writer is not buffering any data before `piped-input-stream` closes the 
> OutputStream.  All together, a ring response could be generated like:
>
> ```
> (response/response                                                         
>                                                                             
>                
>      (ring-io/piped-input-stream                                           
>                                                                             
>                    
>       #(->> (io/make-writer % {})                                         
>                                                                             
>                     
>             (xml/emit (data))                                             
>                                                                             
>                     
>             .flush)))
> ```
>
> A complete example is available at https://www.refheap.com/99829.  When I 
> run the jetty server and use curl, going to http://localhost:8080/stream 
> begins streaming "quickly", where as http://localhost:8080 waits until 
> the entire response is generated.
>
> -
> Nelson
>
> On Mon, Apr 20, 2015 at 11:40 AM, Herwig Hochleitner <hhochl...@gmail.com 
> <javascript:>> wrote:
>
>> The way enlive does it, is to create a lazy sequence of strings. A 
>> response body such as that can be immediately be used by ring. However, I 
>> don't know from the top of my head how to generate it from data.xml.​
>> I'll be glad to get some input on that, otherwise I'll think about this 
>> more, the next time I come around to hacking on it.
>>
>> -- 
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clo...@googlegroups.com 
>> <javascript:>
>> Note that posts from new members are moderated - please be patient with 
>> your first post.
>> To unsubscribe from this group, send email to
>> clojure+u...@googlegroups.com <javascript:>
>> For more options, visit this group at
>> http://groups.google.com/group/clojure?hl=en
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "Clojure" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to clojure+u...@googlegroups.com <javascript:>.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to