[Haskell-cafe] please help me to find errors from my first app

Scott Turner haskell at pkturner.org
Sat Aug 9 08:40:40 EDT 2008

On 2008 August 08 Friday, Changying Li wrote:
> I want to write a reverse proxy like perlbal to practive haskell. Now I
> just write a very simple script to forward any request to
> www.google.com.
> but it dosn't work. I run command ' runhaskell Proxy.hs'  and 'wget
> http://localhost:8080/'. but wget just wait forever and runhaskkell can
> get request. when I break wget, the 'runhaskell' can print response
> returned from www.google.com.

The problem is with
>   request <- hGetContents hRequest
which blocks until wget closes the connection.  Using lazy bytestrings just 
defers the problem slightly. Your processRequest blocks when the 'request' 
string is used.

For some insight into how this can be avoided, see hGetBufNonBlocking.  I'm 
not familiar enough with the Haskell libraries to point you to the ideal 

More information about the Haskell-Cafe mailing list