| Safe Haskell | None | 
|---|---|
| Language | Haskell2010 | 
Network.HTTP.StackClient
Description
Synopsis
- httpJSON :: (MonadIO m, FromJSON a) => Request -> m (Response a)
 - httpLbs :: MonadIO m => Request -> m (Response ByteString)
 - httpLBS :: MonadIO m => Request -> m (Response ByteString)
 - httpNoBody :: MonadIO m => Request -> m (Response ())
 - httpSink :: MonadUnliftIO m => Request -> (Response () -> ConduitM ByteString Void m a) -> m a
 - setUserAgent :: Request -> Request
 - withResponse :: (MonadUnliftIO m, MonadIO n) => Request -> (Response (ConduitM i ByteString n ()) -> m a) -> m a
 - withResponseByManager :: MonadUnliftIO m => Request -> Manager -> (Response BodyReader -> m a) -> m a
 - setRequestMethod :: ByteString -> Request -> Request
 - setRequestHeader :: HeaderName -> [ByteString] -> Request -> Request
 - addRequestHeader :: HeaderName -> ByteString -> Request -> Request
 - setRequestBody :: RequestBody -> Request -> Request
 - setRequestManager :: Manager -> Request -> Request
 - getResponseHeaders :: Response a -> [(HeaderName, ByteString)]
 - getResponseBody :: Response a -> a
 - getResponseStatusCode :: Response a -> Int
 - responseHeaders :: Response body -> ResponseHeaders
 - responseStatus :: Response body -> Status
 - responseBody :: Response body -> body
 - parseRequest :: MonadThrow m => String -> m Request
 - parseRequest_ :: String -> Request
 - defaultRequest :: Request
 - setUri :: MonadThrow m => Request -> URI -> m Request
 - getUri :: Request -> URI
 - path :: Request -> ByteString
 - checkResponse :: Request -> Request -> Response BodyReader -> IO ()
 - parseUrlThrow :: MonadThrow m => String -> m Request
 - requestHeaders :: Request -> RequestHeaders
 - getGlobalManager :: IO Manager
 - applyDigestAuth :: (MonadIO m, MonadThrow n) => ByteString -> ByteString -> Request -> Manager -> m (n Request)
 - displayDigestAuthException :: DigestAuthException -> String
 - data Request
 - data RequestBody
 - data Response body
 - data Manager
 - type Header = (HeaderName, ByteString)
 - type HeaderName = CI ByteString
 - data HttpException = HttpExceptionRequest Request HttpExceptionContent
 - data HttpExceptionContent = StatusCodeException (Response ()) ByteString
 - hAccept :: HeaderName
 - hContentLength :: HeaderName
 - hContentMD5 :: HeaderName
 - hCacheControl :: HeaderName
 - hRange :: HeaderName
 - methodPut :: Method
 - ok200 :: Status
 - partialContent206 :: Status
 - data Proxy
 - useProxy :: Proxy -> ProxyOverride
 - noProxy :: ProxyOverride
 - proxyEnvironment :: Maybe Proxy -> ProxyOverride
 - managerSetProxy :: ProxyOverride -> ManagerSettings -> ManagerSettings
 - formDataBody :: MonadIO m => [Part] -> Request -> m Request
 - partFileRequestBody :: Text -> FilePath -> RequestBody -> Part
 - partBS :: Text -> ByteString -> Part
 - partLBS :: Text -> ByteString -> Part
 
Documentation
httpSink :: MonadUnliftIO m => Request -> (Response () -> ConduitM ByteString Void m a) -> m a Source #
setUserAgent :: Request -> Request Source #
withResponse :: (MonadUnliftIO m, MonadIO n) => Request -> (Response (ConduitM i ByteString n ()) -> m a) -> m a Source #
withResponseByManager :: MonadUnliftIO m => Request -> Manager -> (Response BodyReader -> m a) -> m a Source #
setRequestMethod :: ByteString -> Request -> Request #
Set the request method
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
addRequestHeader :: HeaderName -> ByteString -> Request -> Request #
Add a request header name/value combination
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
setRequestManager :: Manager -> Request -> Request #
Instead of using the default global Manager, use the supplied
 Manager.
Since: http-conduit-2.1.10
getResponseHeaders :: Response a -> [(HeaderName, ByteString)] #
Get all response headers
Since: http-conduit-2.1.10
getResponseBody :: Response a -> a #
Get the response body
Since: http-conduit-2.1.10
getResponseStatusCode :: Response a -> Int #
Get the integral status code of the response
Since: http-conduit-2.1.10
responseHeaders :: Response body -> ResponseHeaders #
Response headers sent by the server.
Since 0.1.0
responseStatus :: Response body -> Status #
Status code of the response.
Since 0.1.0
responseBody :: Response body -> body #
Response body sent by the server.
Since 0.1.0
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
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.
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
path :: Request -> ByteString #
Everything from the host to the query string.
Since 0.1.0
checkResponse :: Request -> Request -> Response BodyReader -> IO () #
Check the response immediately after receiving the status and headers. This can be useful for throwing exceptions on non-success status codes.
In previous versions of http-client, this went under the name
 checkStatus, but was renamed to avoid confusion about the new default
 behavior (doing nothing).
Since: http-client-0.5.0
parseUrlThrow :: 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.
Since: http-client-0.4.30
requestHeaders :: Request -> RequestHeaders #
Custom HTTP request headers
The Content-Length and Transfer-Encoding headers are set automatically
 by this module, and shall not be added to requestHeaders.
If not provided by the user, Host will automatically be set based on
 the host and port fields.
Moreover, the Accept-Encoding header is set implicitly to gzip for
 convenience by default. This behaviour can be overridden if needed, by
 setting the header explicitly to a different value. In order to omit the
 Accept-Header altogether, set it to the empty string "". If you need an
 empty Accept-Header (i.e. requesting the identity encoding), set it to a
 non-empty white-space string, e.g. " ". See RFC 2616 section 14.3 for
 details about the semantics of the Accept-Header field. If you request a
 content-encoding not supported by this module, you will have to decode
 it yourself (see also the decompress field).
Note: Multiple header fields with the same field-name will result in multiple header fields being sent and therefore it's the responsibility of the client code to ensure that the rules from RFC 2616 section 4.2 are honoured.
Since 0.1.0
getGlobalManager :: IO Manager #
Get the current global Manager
Since: http-client-tls-0.2.4
Arguments
| :: (MonadIO m, MonadThrow n) | |
| => ByteString | username  | 
| -> ByteString | password  | 
| -> Request | |
| -> Manager | |
| -> m (n Request) | 
Apply digest authentication to this request.
Note that this function will need to make an HTTP request to the
 server in order to get the nonce, thus the need for a Manager and
 to live in IO. This also means that the request body will be sent
 to the server. If the request body in the supplied Request can
 only be read once, you should replace it with a dummy value.
In the event of successfully generating a digest, this will return
 a Just value. If there is any problem with generating the digest,
 it will return Nothing.
Since: http-client-tls-0.3.1
displayDigestAuthException :: DigestAuthException -> String #
User friendly display of a DigestAuthException
Since: http-client-tls-0.3.3
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
data RequestBody #
When using one of the RequestBodyStream / RequestBodyStreamChunked
 constructors, you must ensure that the GivesPopper can be called multiple
 times.  Usually this is not a problem.
The RequestBodyStreamChunked will send a chunked request body. Note that
 not all servers support this. Only use RequestBodyStreamChunked if you
 know the server you're sending to supports chunked request bodies.
Since 0.1.0
Constructors
| RequestBodyLBS ByteString | |
| RequestBodyBS ByteString | 
Instances
| IsString RequestBody | Since 0.4.12  | 
Defined in Network.HTTP.Client.Types Methods fromString :: String -> RequestBody #  | |
| Semigroup RequestBody | |
Defined in Network.HTTP.Client.Types Methods (<>) :: RequestBody -> RequestBody -> RequestBody # sconcat :: NonEmpty RequestBody -> RequestBody # stimes :: Integral b => b -> RequestBody -> RequestBody #  | |
| Monoid RequestBody | |
Defined in Network.HTTP.Client.Types Methods mempty :: RequestBody # mappend :: RequestBody -> RequestBody -> RequestBody # mconcat :: [RequestBody] -> RequestBody #  | |
A simple representation of the HTTP response.
Since 0.1.0
Instances
| Functor Response | |
| Foldable Response | |
Defined in Network.HTTP.Client.Types Methods fold :: Monoid m => Response m -> 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 | |
Defined in Network.HTTP.Client.Types  | |
| Eq body => Eq (Response body) | |
| Show body => Show (Response body) | |
Keeps track of open connections for keep-alive.
If possible, you should share a single Manager between multiple threads and requests.
Since 0.1.0
Instances
| HasHttpManager Manager | |
Defined in Network.HTTP.Client.Types Methods getHttpManager :: Manager -> Manager #  | |
type Header = (HeaderName, ByteString) #
Header
type HeaderName = CI ByteString #
Header name
data HttpException #
An exception which may be generated by this library
Since: http-client-0.5.0
Constructors
| HttpExceptionRequest Request HttpExceptionContent | Most exceptions are specific to a  Since: http-client-0.5.0  | 
Instances
| Show HttpException | |
Defined in Network.HTTP.Client.Types Methods showsPrec :: Int -> HttpException -> ShowS # show :: HttpException -> String # showList :: [HttpException] -> ShowS #  | |
| Exception HttpException | |
Defined in Network.HTTP.Client.Types Methods toException :: HttpException -> SomeException # fromException :: SomeException -> Maybe HttpException # displayException :: HttpException -> String #  | |
data HttpExceptionContent #
Constructors
| StatusCodeException (Response ()) ByteString | Generated by the  May include the beginning of the response body. Since: http-client-0.5.0  | 
Instances
| Show HttpExceptionContent | |
Defined in Network.HTTP.Client.Types Methods showsPrec :: Int -> HttpExceptionContent -> ShowS # show :: HttpExceptionContent -> String # showList :: [HttpExceptionContent] -> ShowS #  | |
hAccept :: HeaderName #
HTTP Header names according to http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
hContentLength :: HeaderName #
HTTP Header names according to http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
HTTP Header names according to http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
HTTP Header names according to http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
hRange :: HeaderName #
HTTP Header names according to http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
Partial Content 206
Define a HTTP proxy, consisting of a hostname and port number.
useProxy :: Proxy -> ProxyOverride #
Use the given proxy settings, regardless of the proxy value in the Request.
Since 0.4.7
Never connect using a proxy, regardless of the proxy value in the Request.
Since 0.4.7
Arguments
| :: Maybe Proxy | fallback if no environment set  | 
| -> ProxyOverride | 
managerSetProxy :: ProxyOverride -> ManagerSettings -> ManagerSettings #
Set the proxy override value, for both HTTP (insecure) and HTTPS (insecure) connections.
Since 0.4.7
formDataBody :: MonadIO m => [Part] -> Request -> m Request #
Add form data to the Request.
This sets a new requestBody, adds a content-type request header and changes the method to POST.
Arguments
| :: Text | Name of the corresponding <input>.  | 
| -> FilePath | File name to supply to the server.  | 
| -> RequestBody | Data to upload.  | 
| -> Part | 
Construct a Part from form name, filepath and a RequestBody
partFileRequestBody "who_calls" "caller.json" $ RequestBodyBS "{\"caller\":\"Jason J Jason\"}"-- empty upload form partFileRequestBody "file" mempty mempty
The Part does not have a content type associated with it.
Arguments
| :: Text | Name of the corresponding <input>.  | 
| -> ByteString | The body for this   | 
| -> Part | 
Make a Part whose content is a strict ByteString.
The Part does not have a file name or content type associated
 with it.
Arguments
| :: Text | Name of the corresponding <input>.  | 
| -> ByteString | The body for this   | 
| -> Part | 
Make a Part whose content is a lazy ByteString.
The Part does not have a file name or content type associated
 with it.