HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

ModuleHTTP-4000.4.1Haskell98

Network.Browser

Session-level interactions over HTTP.

The Network.Browser goes beyond the basic Network.HTTP functionality in providing support for more involved, and real, request/response interactions over HTTP. Additional features supported are:

  • HTTP Authentication handling

  • Transparent handling of redirects

  • Cookie stores + transmission.

  • Transaction logging

  • Proxy-mediated connections.

Example use:

   do
     (_, rsp)
        <- Network.Browser.browse $ do
              setAllowRedirects True -- handle HTTP redirects
              request $ getRequest "http://www.haskell.org/"
     return (take 100 (rspBody rsp))
  • 13 types
  • 45 values
  • PackageHTTP-4000.4.1
  • Exports58
  • LanguageHaskell98
  • LicenceBSD-3-Clause
  • SourceBrowser.hs
newtypenewtype BrowserAction conn a
#

BrowserAction is the IO monad, but carrying along a BrowserState.

Instances6Monad, Functor, MonadFail, Applicative, MonadIO, MonadState
datadata Proxy
#

HTTP proxies (or not) are represented via Proxy, specifying if a proxy should be used for the request (see setProxy)

Constructors

  • NoProxy

    Don't use a proxy.

  • Proxy String (Maybe Authority)

    Use the proxy given. Should be of the form "http://host:port", "host", "host:port", or "http://host". Additionally, an optional Authority for authentication with the proxy.

setMaxRedirects maxCount sets the maximum number of forwarding hops we are willing to jump through. A no-op if the count is negative; if zero, the max is set to whatever default applies. Notice that setting the max redirects count does not enable following of redirects itself; use setAllowRedirects to do so.

valueuserCookieFilter :: URI -> Cookie -> IO Bool
#

userCookieFilter is a handy acceptance filter, asking the user if he/she is willing to accept an incoming cookie before adding it to the store.

valuesetCookies :: [Cookie] -> BrowserAction t ()
#

setCookies cookies replaces the set of cookies known to the browser to cookies. Useful when wanting to restore cookies used across browse invocations.

valuesetErrHandler :: (String -> IO ()) -> BrowserAction t ()
#

setErrHandler sets the IO action to call when the browser reports running errors. To disable any such, set it to const (return ()).

valuesetOutHandler :: (String -> IO ()) -> BrowserAction t ()
#

setOutHandler sets the IO action to call when the browser chatters info on its running. To disable any such, set it to const (return ()).

setEventHandler onBrowserEvent configures event handling. If onBrowserEvent is Nothing, event handling is turned off; setting it to Just onEv causes the onEv IO action to be notified of browser events during the processing of a request by the Browser pipeline.

valuesetProxy :: Proxy -> BrowserAction t ()
#

setProxy p will disable proxy usage if p is NoProxy. If p is Proxy proxyURL mbAuth, then proxyURL is interpreted as the URL of the proxy to use, possibly authenticating via Authority information in mbAuth.

getProxy returns the current proxy settings. If the auto-proxy flag is set to True, getProxy will perform the necessary

valuesetCheckForProxy :: Bool -> BrowserAction t ()
#

setCheckForProxy flg sets the one-time check for proxy flag to flg. If True, the session will try to determine the proxy server is locally configured. See fetchProxy for details of how this done.

getCheckForProxy returns the current check-proxy setting. Notice that this may not be equal to True if the session has set it to that via setCheckForProxy and subsequently performed some HTTP protocol interactions. i.e., the flag return represents whether a proxy will be checked for again before any future protocol interactions.

valuesetDebugLog :: Maybe String -> BrowserAction t ()
#

setDebugLog mbFile turns off debug logging iff mbFile is Nothing. If set to Just fStem, logs of browser activity is appended to files of the form fStem-url-authority, i.e., fStem is just the prefix for a set of log files, one per host/authority.

valuesetUserAgent :: String -> BrowserAction t ()
#

setUserAgent ua sets the current User-Agent: string to ua. It will be used if no explicit user agent header is found in subsequent requests.

A common form of user agent string is "name/version (details)". For example "cabal-install/0.10.2 (HTTP 4000.1.2)". Including the version of this HTTP package can be helpful if you ever need to track down HTTP compatibility quirks. This version is available via httpPackageVersion. For more info see http://en.wikipedia.org/wiki/User_agent.

valueuriDefaultTo :: URI -> URI -> URI
#

uriDefaultTo a b returns a URI that is consistent with the first argument URI a when read in the context of the second URI b. If the second argument is not sufficient context for determining a full URI then anarchy reins.