[Haskell-beginners] Network.HTTP basics

Barbara Shirtcliff barcs at gmx.com
Fri Apr 1 23:11:27 CEST 2011


Yay!   Thank you!

> ----- Original Message -----
> From: Daniel Fischer
> Sent: 04/01/11 02:04 PM
> To: beginners at haskell.org
> Subject: Re: [Haskell-beginners] Network.HTTP basics
> 
> On Friday 01 April 2011 21:42:19, Barbara Shirtcliff wrote:
> > Hi, this is small, but this is the beginners list, so here goes:
> > 
> > I can see how to use HTTP to request a page. for example, this works:
> > 
> > 
> > Prelude Network.HTTP> let respgoogle = simpleHTTP $ getRequest
> > "http://google.com" Prelude Network.HTTP> respgoogle
> > Right HTTP/1.1 301 Moved Permanently
> > Location: http://www.google.com/
> > Content-Type: text/html; charset=UTF-8
> > Date: Fri, 01 Apr 2011 17:31:25 GMT
> > Expires: Sun, 01 May 2011 17:31:25 GMT
> > Cache-Control: public, max-age=2592000
> > Server: gws
> > Content-Length: 219
> > X-XSS-Protection: 1; mode=block
> > Connection: close
> > 
> > that looks really nice, but hey, what if I want to see what's in the
> > content? It isn't immediately clear to me from the documentation at
> > http://hackage.haskell.org/packages/archive/HTTP/4000.1.1/doc/html/Netw
> > ork-HTTP.html .
> 
> stuff = do
>  answer <- respgoogle
>  case answer of
>  Left connErr -> putStrLn "Got a connection error:" >> print connErr
>  Right result -> do
>  let goodies = rspBody result
>  putStrLn goodies -- or do something sensible
> 
> > 
> > In the end, I'll be working with JSON, here, but I need to know how to
> > get to it, and the examples in the documentation don't work (i.e. don't
> > appear to be up to date). I'm not very experienced with Haskell, so,
> > it's pretty opaque.
> > 
> > Thanks,
> > Bar
> >




More information about the Beginners mailing list