Cool, just what I needed Alan.  Thanks for the help.

On Feb 16, 4:30 pm, Alan Dipert <[email protected]> wrote:
> Hi Matt,
> I think what you're looking for is 
> line-seq:http://richhickey.github.com/clojure/clojure.core-api.html#clojure.co...
>
> In your code, if you pass *in* to line-seq, you'll get back a seq of lines
> (the request headers).  Incidentally, I first ran into line-seq in the
> course of writing a Clojure web server as a first project.  You can see
> line-seq in action on line 52 of this gist, inside the 'handle-request'
> function:http://gist.github.com/203329
>
> I'm pretty new to Clojure myself so there might be a better way.  Hope
> this helps,
>
> Alan
>
> Excerpts from Matt Culbreth's message of 2010-02-16 16:17:57 -0500:
>
>
>
> > Hello Group,
>
> > I'm writing a web server in Clojure and I'd love to have a bit of help
> > on a function I have.
>
> > This function (and athttp://gist.github.com/305909) is used to read
> > the HTTP request from a client and to then act on it:
>
> > (defn handle-request
> >     [in out]
> >     (binding [*in* (BufferedReader. (InputStreamReader. in))]
> >         (let [client-out (OutputStreamWriter. out)]
> >             (loop [lines []]
> >                 (let [input (read-line)]
> >                     (if
> >                         (= (.length input) 0)
> >                         ;; 0 length line means it's time to serve the
> > resource
> >                         (println lines)
> >                         ;; add to the lines vector and keep going
> >                         ;; note it makes the incoming request reversed
> >                         (recur (cons input lines))))))))
>
> > The code works fine; I've left out the bit that actually does
> > something and replaced it with a println call.  It's not very
> > functional feeling though.  The loop/recur and the building of a list
> > seems very imperative to me.  I'd much rather use something from
> > clojure.contrib.io, probably using read-lines or something.
>
> > Thanks for looking and for any suggestions!
>
> > Matt
>
> --
> Alan Diperthttp://alan.dipert.org

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to