Network.HTTP.Simple
This module exports the methods httpHead and httpGet and the
Int value redirectDepth.
The goal of this module is to provide a very simple interface to http
head and get functionality utilizing the more detailed functions
of the Network.HTTP module. There are efforts in place to improve
Network.HTTP, and if those efforts bear fruit, you should likely seek
functionality there instead of this module. This module may even be broken
under a future revision to Network.HTTP.
Because the goal of this module is to be simple, no attempt at cascading
various error states to the caller is made at all. If the function fails
for any reason, Nothing is returned. If you actually want to capture error
states, you should be using Network.HTTP directly.
Here is a small complete haskell program illustrating this library:
module Main where
import Network.URI
import Network.HTTP
import Network.HTTP.Simple
main = do
let s = "http://www.yahoo.com/"
case parseURI s of
Nothing -> error "parse uri error"
Just uri -> do
-- first get headers
tryHead <- httpHead uri
case tryHead of
Nothing -> error "head error"
Just headers -> print headers
-- now try getting content
tryGet <- httpGet uri
case tryGet of
Nothing -> error "get error"
Just content -> print content
return ()
|