Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- httpBS :: MonadUnliftIO m => HttpClientInstrumentationConfig -> Request -> m (Response ByteString)
- httpLBS :: MonadUnliftIO m => HttpClientInstrumentationConfig -> Request -> m (Response ByteString)
- httpNoBody :: MonadUnliftIO m => HttpClientInstrumentationConfig -> Request -> m (Response ())
- httpJSON :: (MonadUnliftIO m, FromJSON a) => HttpClientInstrumentationConfig -> Request -> m (Response a)
- httpJSONEither :: (FromJSON a, MonadUnliftIO m) => HttpClientInstrumentationConfig -> Request -> m (Response (Either JSONException a))
- httpSink :: MonadUnliftIO m => HttpClientInstrumentationConfig -> Request -> (Response () -> ConduitM ByteString Void m a) -> m a
- httpSource :: (MonadUnliftIO m, MonadResource m) => HttpClientInstrumentationConfig -> Request -> (Response (ConduitM i ByteString m ()) -> ConduitM i o m r) -> ConduitM i o m r
- withResponse :: MonadUnliftIO m => HttpClientInstrumentationConfig -> Request -> (Response (ConduitM i ByteString m ()) -> m a) -> m a
- httpClientInstrumentationConfig :: HttpClientInstrumentationConfig
- data HttpClientInstrumentationConfig = HttpClientInstrumentationConfig {}
- setRequestCheckStatus :: Request -> Request
- setRequestIgnoreStatus :: Request -> Request
- defaultRequest :: Request
- parseRequest_ :: String -> Request
- parseRequest :: MonadThrow m => String -> m Request
- data HttpException
- data Proxy = Proxy {
- proxyHost :: ByteString
- proxyPort :: Int
- data Request
- data Response body
- getResponseBody :: Response a -> a
- getResponseHeaders :: Response a -> [(HeaderName, ByteString)]
- getResponseHeader :: HeaderName -> Response a -> [ByteString]
- getResponseStatusCode :: Response a -> Int
- getResponseStatus :: Response a -> Status
- setRequestResponseTimeout :: ResponseTimeout -> Request -> Request
- setRequestProxy :: Maybe Proxy -> Request -> Request
- setRequestManager :: Manager -> Request -> Request
- setRequestBearerAuth :: ByteString -> Request -> Request
- setRequestBasicAuth :: ByteString -> ByteString -> Request -> Request
- setRequestBodyURLEncoded :: [(ByteString, ByteString)] -> Request -> Request
- setRequestBodyFile :: FilePath -> Request -> Request
- setRequestBodySource :: Int64 -> ConduitM () ByteString IO () -> Request -> Request
- setRequestBodyLBS :: ByteString -> Request -> Request
- setRequestBodyJSON :: ToJSON a => a -> Request -> Request
- setRequestBody :: RequestBody -> Request -> Request
- addToRequestQueryString :: Query -> Request -> Request
- setRequestQueryString :: Query -> Request -> Request
- getRequestQueryString :: Request -> Query
- setRequestHeaders :: RequestHeaders -> Request -> Request
- setRequestHeader :: HeaderName -> [ByteString] -> Request -> Request
- getRequestHeader :: HeaderName -> Request -> [ByteString]
- addRequestHeader :: HeaderName -> ByteString -> Request -> Request
- setRequestPath :: ByteString -> Request -> Request
- setRequestPort :: Int -> Request -> Request
- setRequestHost :: ByteString -> Request -> Request
- setRequestSecure :: Bool -> Request -> Request
- setRequestMethod :: ByteString -> Request -> Request
- httpLbs :: MonadIO m => Request -> m (Response ByteString)
- parseRequestThrow_ :: String -> Request
- parseRequestThrow :: MonadThrow m => String -> m Request
- data JSONException
- type ResponseHeaders = [Header]
- type RequestHeaders = [Header]
- type Header = (HeaderName, ByteString)
- type Query = [QueryItem]
- type QueryItem = (ByteString, Maybe ByteString)
Documentation
httpBS :: MonadUnliftIO m => HttpClientInstrumentationConfig -> Request -> m (Response ByteString) Source #
httpLBS :: MonadUnliftIO m => HttpClientInstrumentationConfig -> Request -> m (Response ByteString) Source #
httpNoBody :: MonadUnliftIO m => HttpClientInstrumentationConfig -> Request -> m (Response ()) Source #
httpJSON :: (MonadUnliftIO m, FromJSON a) => HttpClientInstrumentationConfig -> Request -> m (Response a) Source #
httpJSONEither :: (FromJSON a, MonadUnliftIO m) => HttpClientInstrumentationConfig -> Request -> m (Response (Either JSONException a)) Source #
httpSink :: MonadUnliftIO m => HttpClientInstrumentationConfig -> Request -> (Response () -> ConduitM ByteString Void m a) -> m a Source #
httpSource :: (MonadUnliftIO m, MonadResource m) => HttpClientInstrumentationConfig -> Request -> (Response (ConduitM i ByteString m ()) -> ConduitM i o m r) -> ConduitM i o m r Source #
withResponse :: MonadUnliftIO m => HttpClientInstrumentationConfig -> Request -> (Response (ConduitM i ByteString m ()) -> m a) -> m a Source #
setRequestCheckStatus :: Request -> Request #
Modify the request so that non-2XX status codes generate a runtime
StatusCodeException
, by using throwErrorStatusCodes
Since: http-client-0.5.13
setRequestIgnoreStatus :: Request -> Request #
Modify the request so that non-2XX status codes do not generate a runtime
StatusCodeException
.
Since: http-client-0.4.29
A default request value, a GET request of localhost/:80, with an empty request body.
Note that the default checkResponse
does nothing.
Since: http-client-0.4.30
parseRequest_ :: String -> Request #
Same as parseRequest
, but parse errors cause an impure exception.
Mostly useful for static strings which are known to be correctly
formatted.
parseRequest :: MonadThrow m => String -> m Request #
Convert a URL into a Request
.
This function defaults some of the values in Request
, such as setting method
to
GET
and requestHeaders
to []
.
Since this function uses MonadThrow
, the return monad can be anything that is
an instance of MonadThrow
, such as IO
or Maybe
.
You can place the request method at the beginning of the URL separated by a space, e.g.:
@@
parseRequest "POST http://httpbin.org/post"
@@
Note that the request method must be provided as all capital letters.
A Request
created by this function won't cause exceptions on non-2XX
response status codes.
To create a request which throws on non-2XX status codes, see parseUrlThrow
Since: http-client-0.4.30
data HttpException #
An exception which may be generated by this library
Since: http-client-0.5.0
HttpExceptionRequest Request HttpExceptionContent | Most exceptions are specific to a Since: http-client-0.5.0 |
InvalidUrlException String String | A URL (first field) is invalid for a given reason (second argument). Since: http-client-0.5.0 |
Instances
Show HttpException | |
Defined in Network.HTTP.Client.Types showsPrec :: Int -> HttpException -> ShowS # show :: HttpException -> String # showList :: [HttpException] -> ShowS # | |
Exception HttpException | |
Defined in Network.HTTP.Client.Types |
Define a HTTP proxy, consisting of a hostname and port number.
Proxy | |
|
All information on how to connect to a host and what should be sent in the HTTP request.
If you simply wish to download from a URL, see parseRequest
.
The constructor for this data type is not exposed. Instead, you should use
either the defaultRequest
value, or parseRequest
to
construct from a URL, and then use the records below to make modifications.
This approach allows http-client to add configuration options without
breaking backwards compatibility.
For example, to construct a POST request, you could do something like:
initReq <- parseRequest "http://www.example.com/path" let req = initReq { method = "POST" }
For more information, please see http://www.yesodweb.com/book/settings-types.
Since 0.1.0
A simple representation of the HTTP response.
Since 0.1.0
Instances
Functor Response | |
Foldable Response | |
Defined in Network.HTTP.Client.Types fold :: Monoid m => Response m -> m # foldMap :: Monoid m => (a -> m) -> Response a -> m # foldMap' :: Monoid m => (a -> m) -> Response a -> m # foldr :: (a -> b -> b) -> b -> Response a -> b # foldr' :: (a -> b -> b) -> b -> Response a -> b # foldl :: (b -> a -> b) -> b -> Response a -> b # foldl' :: (b -> a -> b) -> b -> Response a -> b # foldr1 :: (a -> a -> a) -> Response a -> a # foldl1 :: (a -> a -> a) -> Response a -> a # elem :: Eq a => a -> Response a -> Bool # maximum :: Ord a => Response a -> a # minimum :: Ord a => Response a -> a # | |
Traversable Response | |
Show body => Show (Response body) | |
getResponseBody :: Response a -> a #
Get the response body
Since: http-conduit-2.1.10
getResponseHeaders :: Response a -> [(HeaderName, ByteString)] #
Get all response headers
Since: http-conduit-2.1.10
getResponseHeader :: HeaderName -> Response a -> [ByteString] #
Get all response header values with the given name
Since: http-conduit-2.1.10
getResponseStatusCode :: Response a -> Int #
Get the integral status code of the response
Since: http-conduit-2.1.10
getResponseStatus :: Response a -> Status #
Get the status of the response
Since: http-conduit-2.1.10
setRequestResponseTimeout :: ResponseTimeout -> Request -> Request #
Set the maximum time to wait for a response
Since: http-conduit-2.3.8
setRequestProxy :: Maybe Proxy -> Request -> Request #
Override the default proxy server settings
Since: http-conduit-2.1.10
setRequestManager :: Manager -> Request -> Request #
Instead of using the default global Manager
, use the supplied
Manager
.
Since: http-conduit-2.1.10
:: ByteString | token |
-> Request | |
-> Request |
Set bearer auth with the given token
Since: http-conduit-2.3.8
:: ByteString | username |
-> ByteString | password |
-> Request | |
-> Request |
Set basic auth with the given username and password
Since: http-conduit-2.1.10
setRequestBodyURLEncoded :: [(ByteString, ByteString)] -> Request -> Request #
Set the request body as URL encoded data
Note: This will change the request method to POST
and set the content-type
to application/x-www-form-urlencoded
Since: http-conduit-2.1.10
setRequestBodyFile :: FilePath -> Request -> Request #
Set the request body as a file
Note: This will not modify the request method. For that, please use
requestMethod
. You likely don't want the default of GET
.
Since: http-conduit-2.1.10
Set the request body as a Source
Note: This will not modify the request method. For that, please use
requestMethod
. You likely don't want the default of GET
.
Since: http-conduit-2.1.10
setRequestBodyLBS :: ByteString -> Request -> Request #
Set the request body as a lazy ByteString
Note: This will not modify the request method. For that, please use
requestMethod
. You likely don't want the default of GET
.
Since: http-conduit-2.1.10
setRequestBodyJSON :: ToJSON a => a -> Request -> Request #
Set the request body as a JSON value
Note: This will not modify the request method. For that, please use
requestMethod
. You likely don't want the default of GET
.
This also sets the Content-Type
to application/json; charset=utf-8
NOTE: Depends on the aeson
cabal flag being enabled
Since: http-conduit-2.1.10
setRequestBody :: RequestBody -> Request -> Request #
Set the request body to the given RequestBody
. You may want to
consider using one of the convenience functions in the modules, e.g.
requestBodyJSON
.
Note: This will not modify the request method. For that, please use
requestMethod
. You likely don't want the default of GET
.
Since: http-conduit-2.1.10
addToRequestQueryString :: Query -> Request -> Request #
Add to the existing query string parameters.
Since: http-conduit-2.3.5
setRequestQueryString :: Query -> Request -> Request #
Set the query string parameters
Since: http-conduit-2.1.10
getRequestQueryString :: Request -> Query #
Get the query string parameters
Since: http-conduit-2.1.10
setRequestHeaders :: RequestHeaders -> Request -> Request #
Set the request headers, wiping out all previously set headers. This
means if you use setRequestHeaders
to set some headers and also use one of
the other setters that modifies the content-type
header (such as
setRequestBodyJSON
), be sure that setRequestHeaders
is evaluated
first.
Since: http-conduit-2.1.10
setRequestHeader :: HeaderName -> [ByteString] -> Request -> Request #
Set the given request header to the given list of values. Removes any previously set header values with the same name.
Since: http-conduit-2.1.10
getRequestHeader :: HeaderName -> Request -> [ByteString] #
Get all request header values for the given name
Since: http-conduit-2.1.10
addRequestHeader :: HeaderName -> ByteString -> Request -> Request #
Add a request header name/value combination
Since: http-conduit-2.1.10
setRequestPath :: ByteString -> Request -> Request #
Lens for the requested path info of the request
Since: http-conduit-2.1.10
setRequestPort :: Int -> Request -> Request #
Set the destination port of the request
Since: http-conduit-2.1.10
setRequestHost :: ByteString -> Request -> Request #
Set the destination host of the request
Since: http-conduit-2.1.10
setRequestSecure :: Bool -> Request -> Request #
Set whether this is a secureHTTPS (True
) or insecureHTTP
(False
) request
Since: http-conduit-2.1.10
setRequestMethod :: ByteString -> Request -> Request #
Set the request method
Since: http-conduit-2.1.10
httpLbs :: MonadIO m => Request -> m (Response ByteString) #
Alternate spelling of httpLBS
Since: http-conduit-2.1.10
parseRequestThrow_ :: String -> Request #
Same as parseRequestThrow
, but parse errors cause an impure
exception. Mostly useful for static strings which are known to be
correctly formatted.
Since: http-conduit-2.3.2
parseRequestThrow :: MonadThrow m => String -> m Request #
Same as parseRequest
, except will throw an HttpException
in the
event of a non-2XX response. This uses throwErrorStatusCodes
to
implement checkResponse
.
Exactly the same as parseUrlThrow
, but has a name that is more
consistent with the other parseRequest functions.
Since: http-conduit-2.3.2
data JSONException #
An exception that can occur when parsing JSON
NOTE: Depends on the aeson
cabal flag being enabled
Since: http-conduit-2.1.10
JSONParseException Request (Response ()) ParseError | |
JSONConversionException Request (Response Value) String |
Instances
Show JSONException | |
Defined in Network.HTTP.Simple showsPrec :: Int -> JSONException -> ShowS # show :: JSONException -> String # showList :: [JSONException] -> ShowS # | |
Exception JSONException | |
Defined in Network.HTTP.Simple |
type ResponseHeaders = [Header] #
Response Headers
type RequestHeaders = [Header] #
Request Headers
type Header = (HeaderName, ByteString) #
Header
Query.
General form: a=b&c=d
, but if the value is Nothing, it becomes
a&c=d
.
type QueryItem = (ByteString, Maybe ByteString) #
Query item