HTTP-Simple-0.1: Enable simple wrappers to Network.HTTPSource codeContentsIndex
Network.HTTP.Simple
Description

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 ()
Synopsis
httpHead :: URI -> IO (Maybe [Header])
httpGet :: URI -> IO (Maybe String)
redirectDepth :: Int
Documentation
httpHead :: URI -> IO (Maybe [Header])Source
The httpHead function will return a list of Headers for a given request. Should the request fail for any reason, Nothing is returned.
httpGet :: URI -> IO (Maybe String)Source
The httpGet function will return the http response content for a given request. Should the request fail for any reason, Nothing is returned. This function simply calls the function httpGetN with a seed value of 0 to indicate an initial redirect depth level.
redirectDepth :: IntSource
redirectDepth stipulates the number of http redirects we will allow for any given request, defaulted to 10.
Produced by Haddock version 2.3.0