Re: How to: convert output stream into an input stream

2011-12-16 Thread Trevor
This is great. Thanks for the help. On Dec 16, 2:55 am, Alan Malloy wrote: > Edit: you should probably use with-open at some point, to make sure > you close the output writer. I copied pretty badly from my own > example :P. So more like: > > (let [pipe-in (PipedInputStream.)] >   (future        

Re: How to: convert output stream into an input stream

2011-12-16 Thread Alan Malloy
Edit: you should probably use with-open at some point, to make sure you close the output writer. I copied pretty badly from my own example :P. So more like: (let [pipe-in (PipedInputStream.)] (future; new thread to prevent blocking deadlock (with-open [out (-> pipe-in (Pi

Re: How to: convert output stream into an input stream

2011-12-16 Thread Alan Malloy
You can't really do this in a single thread without risking blocking. But with another thread, it's fairly simple. For example, I do this in my gzip-middleware, copying an InputStream through a pipe with GZIP wrapping: https://github.com/amalloy/ring-gzip-middleware/blob/master/src/ring/middleware

Re: How to: convert output stream into an input stream

2011-12-16 Thread Shantanu Kumar
On Dec 16, 2:01 am, Trevor wrote: > I have created an output  stream, which appears to work fine, however > I get an error when trying to convert the output stream into an input > stream for use in ring: > > ('use [clojure.java.io :only [input-stream]]) > > => (with-out-str (ofn var)) > "it work

How to: convert output stream into an input stream

2011-12-15 Thread Trevor
I have created an output stream, which appears to work fine, however I get an error when trying to convert the output stream into an input stream for use in ring: ('use [clojure.java.io :only [input-stream]]) => (with-out-str (ofn var)) "it works!" Now when I use ring: {:body (input-stream (ofn