[Haskell-beginners] Network.HTTP basics

Antoine Latter aslatter at gmail.com
Fri Apr 1 22:00:44 CEST 2011

On Fri, Apr 1, 2011 at 2:42 PM, Barbara Shirtcliff <barcs at gmx.com> 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/Network-HTTP.html .
> 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.


The Response type is exported non-abstractly by the HTTP package, with
documentation here:


You can either pattern-match on the response, or use the rspBody
function to extract the response body.

Take care,

More information about the Beginners mailing list