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

Modulewreq-0.5.4.3Haskell98

Network.Wreq.Session

The functions in this module use a Session to handle the following common needs:

  • TCP connection reuse. This is important for performance when multiple requests go to a single server, particularly if TLS is being used.

  • Transparent cookie management. Any cookies set by the server persist from one request to the next. (Bypass this overhead using newAPISession.)

This module is designed to be used alongside the Network.Wreq module. Typical usage will look like this:

import Network.Wreq
import qualified Network.Wreq.Session as Sess

main = do
  sess <- Sess.newSession
  Sess.get sess "http://httpbin.org/get"

We create a Session using newSession, then pass the session to subsequent functions. When talking to a REST-like service that does not use cookies, it is more efficient to use newAPISession.

Note the use of qualified import statements in the examples above, so that we can refer unambiguously to the Session-specific implementation of HTTP GET.

One Manager (possibly set with newSessionControl) is used for all session requests. The manager settings in the Options parameter for the getWith, postWith and similar functions is ignored.

  • 1 type
  • 26 values
  • Packagewreq-0.5.4.3
  • Exports27
  • LanguageHaskell98
  • LicenceBSD-3-Clause
  • SourceSession.hs

Session creation

5 declarations
datadata Session
#

A session that spans multiple requests. This is responsible for cookie management and TCP connection reuse.

Instances1Show
  • Show SessionDefined in wreq-0.5.4.3 · Network.Wreq.Internal.Types

Create a session.

This uses the default session manager settings, but does not manage cookies. It is intended for use with REST-like HTTP-based APIs, which typically do not use cookies.

valuewithSession :: (Session -> IO a) -> IO a
#

Deprecated. Use newSession instead.

Create a Session, passing it to the given function. The Session will no longer be valid after that function returns.

This session manages cookies and uses default session manager configuration.

valuewithAPISession :: (Session -> IO a) -> IO a
#

Deprecated. Use newAPISession instead.

Create a session.

This uses the default session manager settings, but does not manage cookies. It is intended for use with REST-like HTTP-based APIs, which typically do not use cookies.

More control-oriented session creation

Get information about session state

HTTP verbs

7 declarations

Configurable verbs

Extending a session

1 declaration