[Haskell-cafe] HTTP actions & proxy server

Stefan Kersten sk at k-hornz.de
Mon Nov 19 19:19:22 EST 2007


On 16.11.2007, at 13:55, Jim Burton wrote:
> The docs say "Should be of the form http://host:port, host,  
> host:port, or
> http://host" but none of the variations work. Any ideas where I  
> might find
> an example of code that does this?

this works for me (modulo error handling):

simpleHTTP' :: Request -> IO (Result Response)
simpleHTTP' req = do
     proxy <- catch
                 (getEnv "HTTP_PROXY" >>= return . (flip Proxy Nothing))
                 (\_ -> return NoProxy)
     (_, resp) <- browse (setProxy proxy >> request req)
     return (Right resp)

i.e. run the request in the browser monad.

<sk>



More information about the Haskell-Cafe mailing list