wreq-0.5.3.1: An easy-to-use HTTP client library.

Copyright(c) 2014 Bryan O'Sullivan
LicenseBSD-style
Maintainerbos@serpentine.com
Stabilityexperimental
PortabilityGHC
Safe HaskellNone
LanguageHaskell98

Network.Wreq.Types

Contents

Description

HTTP client types.

Synopsis

Client configuration

data Options Source #

Options for configuring a client.

Constructors

Options 

Fields

  • manager :: Mgr

    Either configuration for a Manager, or an actual Manager.

    If only ManagerSettings are provided, then by default a new Manager will be created for each request.

    Note: when issuing HTTP requests using Options-based functions from the the Network.Wreq.Session module (getWith, putWith, etc.), this field will be ignored.

    An example of using a specific manager:

    import Network.HTTP.Client (withManager)
    
    withManager $ \mgr -> do
      let opts = defaults { manager = Right mgr }
      getWith opts "http://httpbin.org/get"
     

    An example of changing settings (this will use a separate Manager for every request, so make sense only if you're issuing a tiny handful of requets):

    import Network.HTTP.Client (defaultManagerSettings)
    
    let settings = defaultManagerSettings { managerConnCount = 5 }
        opts = defaults { manager = Left settings }
    getWith opts "http://httpbin.org/get"
     
  • proxy :: Maybe Proxy

    Host name and port for a proxy to use, if any.

  • auth :: Maybe Auth

    Authentication information.

    Example (note the use of TLS):

    let opts = defaults { auth = basicAuth "user" "pass" }
    getWith opts "https://httpbin.org/basic-auth/user/pass"
     
  • headers :: [Header]

    Additional headers to send with each request.

    let opts = defaults { headers = [("Accept", "*/*")] }
    getWith opts "http://httpbin.org/get"
     
  • params :: [(Text, Text)]

    Key-value pairs to assemble into a query string to add to the end of a URL.

    For example, given:

    let opts = defaults { params = [("sort", "ascending"), ("key", "name")] }
    getWith opts "http://httpbin.org/get"
     

    This will generate a URL of the form:

    http://httpbin.org/get?sort=ascending&key=name
  • redirects :: Int

    The maximum number of HTTP redirects to follow before giving up and throwing an exception.

    In this example, a HttpException will be thrown with a TooManyRedirects constructor, because the maximum number of redirects allowed will be exceeded:

    let opts = defaults { redirects = 3 }
    getWith opts "http://httpbin.org/redirect/5"
     
  • cookies :: Maybe CookieJar

    Cookies to set when issuing requests.

    Note: when issuing HTTP requests using Options-based functions from the the Network.Wreq.Session module (getWith, putWith, etc.), this field will be used only for the first HTTP request to be issued during a Session. Any changes changes made for subsequent requests will be ignored.

  • checkResponse :: Maybe ResponseChecker

    Function that checks the status code and potentially returns an exception.

    This defaults to Nothing, which will just use the default of Request which throws a StatusException if the status is not 2XX.

Instances
Show Options Source # 
Instance details

Defined in Network.Wreq.Internal.Types

Methods

showsPrec :: Int -> Options -> ShowS

show :: Options -> String

showList :: [Options] -> ShowS

data Auth Source #

Supported authentication types.

Do not use HTTP authentication unless you are using TLS encryption. These authentication tokens can easily be captured and reused by an attacker if transmitted in the clear.

Constructors

BasicAuth ByteString ByteString

Basic authentication. This consists of a plain username and password.

OAuth2Bearer ByteString

An OAuth2 bearer token. This is treated by many services as the equivalent of a username and password.

OAuth2Token ByteString

A not-quite-standard OAuth2 bearer token (that seems to be used only by GitHub). This is treated by whoever accepts it as the equivalent of a username and password.

AWSAuth AWSAuthVersion ByteString ByteString (Maybe ByteString)

Amazon Web Services request signing AWSAuthVersion key secret (optional: session-token)

AWSFullAuth AWSAuthVersion ByteString ByteString (Maybe ByteString) (Maybe (ByteString, ByteString))

Amazon Web Services request signing AWSAuthVersion key secret Maybe (service, region)

OAuth1 ByteString ByteString ByteString ByteString

OAuth1 request signing OAuth1 consumerToken consumerSecret token secret

Instances
Eq Auth Source # 
Instance details

Defined in Network.Wreq.Internal.Types

Methods

(==) :: Auth -> Auth -> Bool

(/=) :: Auth -> Auth -> Bool

Show Auth Source # 
Instance details

Defined in Network.Wreq.Internal.Types

Methods

showsPrec :: Int -> Auth -> ShowS

show :: Auth -> String

showList :: [Auth] -> ShowS

data AWSAuthVersion Source #

Constructors

AWSv4

AWS request signing version 4

Instances
Eq AWSAuthVersion Source # 
Instance details

Defined in Network.Wreq.Internal.Types

Show AWSAuthVersion Source # 
Instance details

Defined in Network.Wreq.Internal.Types

Methods

showsPrec :: Int -> AWSAuthVersion -> ShowS

show :: AWSAuthVersion -> String

showList :: [AWSAuthVersion] -> ShowS

type ResponseChecker = Request -> Response BodyReader -> IO () Source #

A function that checks the result of a HTTP request and potentially returns an exception.

Request payloads

data Payload where Source #

A product type for representing more complex payload types.

Constructors

Raw :: ContentType -> RequestBody -> Payload 
Instances
Putable Payload Source # 
Instance details

Defined in Network.Wreq.Types

Methods

putPayload :: Payload -> Request -> IO Request Source #

Postable Payload Source # 
Instance details

Defined in Network.Wreq.Types

Methods

postPayload :: Payload -> Request -> IO Request Source #

class Postable a where Source #

A type that can be converted into a POST request payload.

Minimal complete definition

Nothing

Methods

postPayload :: a -> Request -> IO Request Source #

postPayload :: Putable a => a -> Request -> IO Request Source #

Instances
Postable ByteString Source # 
Instance details

Defined in Network.Wreq.Types

Methods

postPayload :: ByteString -> Request -> IO Request Source #

Postable ByteString Source # 
Instance details

Defined in Network.Wreq.Types

Methods

postPayload :: ByteString -> Request -> IO Request Source #

Postable FormParam Source # 
Instance details

Defined in Network.Wreq.Types

Methods

postPayload :: FormParam -> Request -> IO Request Source #

Postable Payload Source # 
Instance details

Defined in Network.Wreq.Types

Methods

postPayload :: Payload -> Request -> IO Request Source #

Postable Encoding Source # 
Instance details

Defined in Network.Wreq.Types

Methods

postPayload :: Encoding -> Request -> IO Request Source #

Postable Value Source # 
Instance details

Defined in Network.Wreq.Types

Methods

postPayload :: Value -> Request -> IO Request Source #

Postable Part Source # 
Instance details

Defined in Network.Wreq.Types

Methods

postPayload :: Part -> Request -> IO Request Source #

Postable [(ByteString, ByteString)] Source # 
Instance details

Defined in Network.Wreq.Types

Methods

postPayload :: [(ByteString, ByteString)] -> Request -> IO Request Source #

Postable [FormParam] Source # 
Instance details

Defined in Network.Wreq.Types

Methods

postPayload :: [FormParam] -> Request -> IO Request Source #

Postable [Part] Source # 
Instance details

Defined in Network.Wreq.Types

Methods

postPayload :: [Part] -> Request -> IO Request Source #

Postable (ByteString, ByteString) Source # 
Instance details

Defined in Network.Wreq.Types

Methods

postPayload :: (ByteString, ByteString) -> Request -> IO Request Source #

class Putable a where Source #

A type that can be converted into a PUT request payload.

Methods

putPayload :: a -> Request -> IO Request Source #

Represent a value in the request body (and perhaps the headers) of a PUT request.

Instances
Putable ByteString Source # 
Instance details

Defined in Network.Wreq.Types

Methods

putPayload :: ByteString -> Request -> IO Request Source #

Putable ByteString Source # 
Instance details

Defined in Network.Wreq.Types

Methods

putPayload :: ByteString -> Request -> IO Request Source #

Putable FormParam Source # 
Instance details

Defined in Network.Wreq.Types

Methods

putPayload :: FormParam -> Request -> IO Request Source #

Putable Payload Source # 
Instance details

Defined in Network.Wreq.Types

Methods

putPayload :: Payload -> Request -> IO Request Source #

Putable Encoding Source # 
Instance details

Defined in Network.Wreq.Types

Methods

putPayload :: Encoding -> Request -> IO Request Source #

Putable Value Source # 
Instance details

Defined in Network.Wreq.Types

Methods

putPayload :: Value -> Request -> IO Request Source #

Putable Part Source # 
Instance details

Defined in Network.Wreq.Types

Methods

putPayload :: Part -> Request -> IO Request Source #

Putable [(ByteString, ByteString)] Source # 
Instance details

Defined in Network.Wreq.Types

Methods

putPayload :: [(ByteString, ByteString)] -> Request -> IO Request Source #

Putable [FormParam] Source # 
Instance details

Defined in Network.Wreq.Types

Methods

putPayload :: [FormParam] -> Request -> IO Request Source #

Putable [Part] Source # 
Instance details

Defined in Network.Wreq.Types

Methods

putPayload :: [Part] -> Request -> IO Request Source #

Putable (ByteString, ByteString) Source # 
Instance details

Defined in Network.Wreq.Types

Methods

putPayload :: (ByteString, ByteString) -> Request -> IO Request Source #

URL-encoded forms

data FormParam where Source #

A key/value pair for an application/x-www-form-urlencoded POST request body.

Constructors

(:=) :: FormValue v => ByteString -> v -> FormParam infixr 3 
Instances
Show FormParam Source # 
Instance details

Defined in Network.Wreq.Internal.Types

Methods

showsPrec :: Int -> FormParam -> ShowS

show :: FormParam -> String

showList :: [FormParam] -> ShowS

Putable FormParam Source # 
Instance details

Defined in Network.Wreq.Types

Methods

putPayload :: FormParam -> Request -> IO Request Source #

Postable FormParam Source # 
Instance details

Defined in Network.Wreq.Types

Methods

postPayload :: FormParam -> Request -> IO Request Source #

Putable [FormParam] Source # 
Instance details

Defined in Network.Wreq.Types

Methods

putPayload :: [FormParam] -> Request -> IO Request Source #

Postable [FormParam] Source # 
Instance details

Defined in Network.Wreq.Types

Methods

postPayload :: [FormParam] -> Request -> IO Request Source #

class FormValue a where Source #

A type that can be rendered as the value portion of a key/value pair for use in an application/x-www-form-urlencoded POST body. Intended for use with the FormParam type.

The instances for String, strict Text, and lazy Text are all encoded using UTF-8 before being URL-encoded.

The instance for Maybe gives an empty string on Nothing, and otherwise uses the contained type's instance.

Methods

renderFormValue :: a -> ByteString Source #

Render the given value.

Instances
FormValue Double Source # 
Instance details

Defined in Network.Wreq.Types

Methods

renderFormValue :: Double -> ByteString Source #

FormValue Float Source # 
Instance details

Defined in Network.Wreq.Types

Methods

renderFormValue :: Float -> ByteString Source #

FormValue Int Source # 
Instance details

Defined in Network.Wreq.Types

Methods

renderFormValue :: Int -> ByteString Source #

FormValue Int8 Source # 
Instance details

Defined in Network.Wreq.Types

Methods

renderFormValue :: Int8 -> ByteString Source #

FormValue Int16 Source # 
Instance details

Defined in Network.Wreq.Types

Methods

renderFormValue :: Int16 -> ByteString Source #

FormValue Int32 Source # 
Instance details

Defined in Network.Wreq.Types

Methods

renderFormValue :: Int32 -> ByteString Source #

FormValue Int64 Source # 
Instance details

Defined in Network.Wreq.Types

Methods

renderFormValue :: Int64 -> ByteString Source #

FormValue Integer Source # 
Instance details

Defined in Network.Wreq.Types

Methods

renderFormValue :: Integer -> ByteString Source #

FormValue Word Source # 
Instance details

Defined in Network.Wreq.Types

Methods

renderFormValue :: Word -> ByteString Source #

FormValue Word8 Source # 
Instance details

Defined in Network.Wreq.Types

Methods

renderFormValue :: Word8 -> ByteString Source #

FormValue Word16 Source # 
Instance details

Defined in Network.Wreq.Types

Methods

renderFormValue :: Word16 -> ByteString Source #

FormValue Word32 Source # 
Instance details

Defined in Network.Wreq.Types

Methods

renderFormValue :: Word32 -> ByteString Source #

FormValue Word64 Source # 
Instance details

Defined in Network.Wreq.Types

Methods

renderFormValue :: Word64 -> ByteString Source #

FormValue () Source # 
Instance details

Defined in Network.Wreq.Types

Methods

renderFormValue :: () -> ByteString Source #

FormValue String Source # 
Instance details

Defined in Network.Wreq.Types

Methods

renderFormValue :: String -> ByteString Source #

FormValue Text Source # 
Instance details

Defined in Network.Wreq.Types

Methods

renderFormValue :: Text -> ByteString Source #

FormValue ByteString Source # 
Instance details

Defined in Network.Wreq.Types

Methods

renderFormValue :: ByteString -> ByteString Source #

FormValue ByteString Source # 
Instance details

Defined in Network.Wreq.Types

Methods

renderFormValue :: ByteString -> ByteString0 Source #

FormValue Text Source # 
Instance details

Defined in Network.Wreq.Types

Methods

renderFormValue :: Text -> ByteString Source #

FormValue Builder Source # 
Instance details

Defined in Network.Wreq.Types

Methods

renderFormValue :: Builder -> ByteString Source #

FormValue a => FormValue (Maybe a) Source # 
Instance details

Defined in Network.Wreq.Types

Methods

renderFormValue :: Maybe a -> ByteString Source #

Headers

type ContentType = ByteString Source #

A MIME content type, e.g. "application/octet-stream".

data Link Source #

An element of a Link header.

Constructors

Link 

Fields

Errors

data JSONError Source #

The error type used by asJSON and asValue if a failure occurs when parsing a response body as JSON.

Constructors

JSONError String 
Instances
Show JSONError Source # 
Instance details

Defined in Network.Wreq.Internal.Types

Methods

showsPrec :: Int -> JSONError -> ShowS

show :: JSONError -> String

showList :: [JSONError] -> ShowS

Exception JSONError Source # 
Instance details

Defined in Network.Wreq.Internal.Types

Methods

toException :: JSONError -> SomeException

fromException :: SomeException -> Maybe JSONError

displayException :: JSONError -> String

Request handling

data Req Source #

A request that is ready to be submitted.

reqURL :: Req -> ByteString Source #

Return the URL associated with the given Req.

This includes the port number if not standard, and the query string if one exists.

type Run body = Req -> IO (Response body) Source #

A function that runs a request and returns the associated response.

Orphan instances

FormValue Double Source # 
Instance details

Methods

renderFormValue :: Double -> ByteString Source #

FormValue Float Source # 
Instance details

Methods

renderFormValue :: Float -> ByteString Source #

FormValue Int Source # 
Instance details

Methods

renderFormValue :: Int -> ByteString Source #

FormValue Int8 Source # 
Instance details

Methods

renderFormValue :: Int8 -> ByteString Source #

FormValue Int16 Source # 
Instance details

Methods

renderFormValue :: Int16 -> ByteString Source #

FormValue Int32 Source # 
Instance details

Methods

renderFormValue :: Int32 -> ByteString Source #

FormValue Int64 Source # 
Instance details

Methods

renderFormValue :: Int64 -> ByteString Source #

FormValue Integer Source # 
Instance details

Methods

renderFormValue :: Integer -> ByteString Source #

FormValue Word Source # 
Instance details

Methods

renderFormValue :: Word -> ByteString Source #

FormValue Word8 Source # 
Instance details

Methods

renderFormValue :: Word8 -> ByteString Source #

FormValue Word16 Source # 
Instance details

Methods

renderFormValue :: Word16 -> ByteString Source #

FormValue Word32 Source # 
Instance details

Methods

renderFormValue :: Word32 -> ByteString Source #

FormValue Word64 Source # 
Instance details

Methods

renderFormValue :: Word64 -> ByteString Source #

FormValue () Source # 
Instance details

Methods

renderFormValue :: () -> ByteString Source #

FormValue String Source # 
Instance details

Methods

renderFormValue :: String -> ByteString Source #

FormValue Text Source # 
Instance details

Methods

renderFormValue :: Text -> ByteString Source #

FormValue ByteString Source # 
Instance details

Methods

renderFormValue :: ByteString -> ByteString Source #

FormValue ByteString Source # 
Instance details

Methods

renderFormValue :: ByteString -> ByteString0 Source #

FormValue Text Source # 
Instance details

Methods

renderFormValue :: Text -> ByteString Source #

FormValue Builder Source # 
Instance details

Methods

renderFormValue :: Builder -> ByteString Source #

Putable ByteString Source # 
Instance details

Methods

putPayload :: ByteString -> Request -> IO Request Source #

Putable ByteString Source # 
Instance details

Methods

putPayload :: ByteString -> Request -> IO Request Source #

Putable FormParam Source # 
Instance details

Methods

putPayload :: FormParam -> Request -> IO Request Source #

Putable Payload Source # 
Instance details

Methods

putPayload :: Payload -> Request -> IO Request Source #

Putable Encoding Source # 
Instance details

Methods

putPayload :: Encoding -> Request -> IO Request Source #

Putable Value Source # 
Instance details

Methods

putPayload :: Value -> Request -> IO Request Source #

Putable Part Source # 
Instance details

Methods

putPayload :: Part -> Request -> IO Request Source #

Postable ByteString Source # 
Instance details

Methods

postPayload :: ByteString -> Request -> IO Request Source #

Postable ByteString Source # 
Instance details

Methods

postPayload :: ByteString -> Request -> IO Request Source #

Postable FormParam Source # 
Instance details

Methods

postPayload :: FormParam -> Request -> IO Request Source #

Postable Payload Source # 
Instance details

Methods

postPayload :: Payload -> Request -> IO Request Source #

Postable Encoding Source # 
Instance details

Methods

postPayload :: Encoding -> Request -> IO Request Source #

Postable Value Source # 
Instance details

Methods

postPayload :: Value -> Request -> IO Request Source #

Postable Part Source # 
Instance details

Methods

postPayload :: Part -> Request -> IO Request Source #

FormValue a => FormValue (Maybe a) Source # 
Instance details

Methods

renderFormValue :: Maybe a -> ByteString Source #

Putable [(ByteString, ByteString)] Source # 
Instance details

Methods

putPayload :: [(ByteString, ByteString)] -> Request -> IO Request Source #

Putable [FormParam] Source # 
Instance details

Methods

putPayload :: [FormParam] -> Request -> IO Request Source #

Putable [Part] Source # 
Instance details

Methods

putPayload :: [Part] -> Request -> IO Request Source #

Postable [(ByteString, ByteString)] Source # 
Instance details

Methods

postPayload :: [(ByteString, ByteString)] -> Request -> IO Request Source #

Postable [FormParam] Source # 
Instance details

Methods

postPayload :: [FormParam] -> Request -> IO Request Source #

Postable [Part] Source # 
Instance details

Methods

postPayload :: [Part] -> Request -> IO Request Source #

Putable (ByteString, ByteString) Source # 
Instance details

Methods

putPayload :: (ByteString, ByteString) -> Request -> IO Request Source #

Postable (ByteString, ByteString) Source # 
Instance details

Methods

postPayload :: (ByteString, ByteString) -> Request -> IO Request Source #