Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Meta-module that reexports many Imm sub-modules.
Synopsis
- data Callback = Callback {
- _executable :: FilePath
- _arguments :: [Text]
- data Proxy = Proxy {
- proxyHost :: ByteString
- proxyPort :: Int
- data HttpException
- data Manager
- data StreamFileStatus = StreamFileStatus {}
- class HasHttpManager a where
- getHttpManager :: a -> Manager
- data ProxyOverride
- data ManagerSettings
- data Response body
- data ResponseTimeout
- data Request
- type GivesPopper a = NeedsPopper a -> IO a
- type NeedsPopper a = Popper -> IO a
- type Popper = IO ByteString
- data RequestBody
- data CookieJar
- data Cookie = Cookie {}
- data HttpExceptionContent
- = StatusCodeException (Response ()) ByteString
- | TooManyRedirects [Response ByteString]
- | OverlongHeaders
- | ResponseTimeout
- | ConnectionTimeout
- | ConnectionFailure SomeException
- | InvalidStatusLine ByteString
- | InvalidHeader ByteString
- | InvalidRequestHeader ByteString
- | InternalException SomeException
- | ProxyConnectException ByteString Int Status
- | NoResponseDataReceived
- | TlsNotSupported
- | WrongRequestBodyStreamSize Word64 Word64
- | ResponseBodyTooShort Word64 Word64
- | InvalidChunkHeaders
- | IncompleteHeaders
- | InvalidDestinationHost ByteString
- | HttpZlibException ZlibException
- | InvalidProxyEnvironmentVariable Text Text
- | ConnectionClosed
- | InvalidProxySettings Text
- type BodyReader = IO ByteString
- data HistoriedResponse body
- data CallbackMessage = CallbackMessage {}
- data FeedLocation = FeedLocation URI Text
- type UID = Int
- data FeedQuery
- newtype FeedDefinition = FeedDefinition {
- _feedTitle :: Text
- data FeedItem = FeedItem {
- _itemDate :: Maybe UTCTime
- _itemTitle :: Text
- _itemContent :: Text
- _itemLinks :: [Link]
- _itemIdentifier :: Text
- _itemAuthors :: [Author]
- data Author = Author {
- _authorName :: Text
- _authorEmail :: Text
- _authorURI :: Maybe AnyURI
- data LogLevel
- log :: Handle m -> LogLevel -> Doc AnsiStyle -> m ()
- getLogLevel :: Handle m -> m LogLevel
- setLogLevel :: Handle m -> LogLevel -> m ()
- newManager :: ManagerSettings -> IO Manager
- equalCookie :: Cookie -> Cookie -> Bool
- equivCookie :: Cookie -> Cookie -> Bool
- compareCookies :: Cookie -> Cookie -> Ordering
- equalCookieJar :: CookieJar -> CookieJar -> Bool
- equivCookieJar :: CookieJar -> CookieJar -> Bool
- makeConnection :: IO ByteString -> (ByteString -> IO ()) -> IO () -> IO Connection
- socketConnection :: Socket -> Int -> IO Connection
- strippedHostName :: String -> String
- brRead :: BodyReader -> IO ByteString
- brReadSome :: BodyReader -> Int -> IO ByteString
- brConsume :: BodyReader -> IO [ByteString]
- parseUrl :: MonadThrow m => String -> m Request
- parseUrlThrow :: MonadThrow m => String -> m Request
- throwErrorStatusCodes :: MonadIO m => Request -> Response BodyReader -> m ()
- parseRequest :: MonadThrow m => String -> m Request
- parseRequest_ :: String -> Request
- requestFromURI :: MonadThrow m => URI -> m Request
- requestFromURI_ :: URI -> Request
- getUri :: Request -> URI
- defaultRequest :: Request
- applyBasicAuth :: ByteString -> ByteString -> Request -> Request
- applyBearerAuth :: ByteString -> Request -> Request
- applyBasicProxyAuth :: ByteString -> ByteString -> Request -> Request
- urlEncodedBody :: [(ByteString, ByteString)] -> Request -> Request
- setRequestIgnoreStatus :: Request -> Request
- setRequestCheckStatus :: Request -> Request
- setQueryString :: [(ByteString, Maybe ByteString)] -> Request -> Request
- setQueryStringPartialEscape :: [(ByteString, [EscapeItem])] -> Request -> Request
- streamFile :: FilePath -> IO RequestBody
- observedStreamFile :: (StreamFileStatus -> IO ()) -> FilePath -> IO RequestBody
- getOriginalRequest :: Response a -> Request
- rawConnectionModifySocket :: (Socket -> IO ()) -> IO (Maybe HostAddress -> String -> Int -> IO Connection)
- rawConnectionModifySocketSize :: (Socket -> IO ()) -> IO (Int -> Maybe HostAddress -> String -> Int -> IO Connection)
- defaultManagerSettings :: ManagerSettings
- closeManager :: Manager -> IO ()
- withManager :: ManagerSettings -> (Manager -> IO a) -> IO a
- proxyFromRequest :: ProxyOverride
- noProxy :: ProxyOverride
- useProxy :: Proxy -> ProxyOverride
- useProxySecureWithoutConnect :: Proxy -> ProxyOverride
- proxyEnvironment :: Maybe Proxy -> ProxyOverride
- proxyEnvironmentNamed :: Text -> Maybe Proxy -> ProxyOverride
- defaultProxy :: ProxyOverride
- isIpAddress :: ByteString -> Bool
- domainMatches :: ByteString -> ByteString -> Bool
- defaultPath :: Request -> ByteString
- pathMatches :: ByteString -> ByteString -> Bool
- createCookieJar :: [Cookie] -> CookieJar
- destroyCookieJar :: CookieJar -> [Cookie]
- removeExistingCookieFromCookieJar :: Cookie -> CookieJar -> (Maybe Cookie, CookieJar)
- isPotentiallyTrustworthyOrigin :: Bool -> ByteString -> Bool
- evictExpiredCookies :: CookieJar -> UTCTime -> CookieJar
- insertCookiesIntoRequest :: Request -> CookieJar -> UTCTime -> (Request, CookieJar)
- computeCookieString :: Request -> CookieJar -> UTCTime -> Bool -> (ByteString, CookieJar)
- updateCookieJar :: Response a -> Request -> UTCTime -> CookieJar -> (CookieJar, Response a)
- receiveSetCookie :: SetCookie -> Request -> UTCTime -> Bool -> CookieJar -> CookieJar
- insertCheckedCookie :: Cookie -> CookieJar -> Bool -> CookieJar
- generateCookie :: SetCookie -> Request -> UTCTime -> Bool -> Maybe Cookie
- withResponse :: Request -> Manager -> (Response BodyReader -> IO a) -> IO a
- httpLbs :: Request -> Manager -> IO (Response ByteString)
- httpNoBody :: Request -> Manager -> IO (Response ())
- responseOpen :: Request -> Manager -> IO (Response BodyReader)
- responseClose :: Response a -> IO ()
- withConnection :: Request -> Manager -> (Connection -> IO a) -> IO a
- responseOpenHistory :: Request -> Manager -> IO (HistoriedResponse BodyReader)
- withResponseHistory :: Request -> Manager -> (HistoriedResponse BodyReader -> IO a) -> IO a
- managerSetInsecureProxy :: ProxyOverride -> ManagerSettings -> ManagerSettings
- managerSetSecureProxy :: ProxyOverride -> ManagerSettings -> ManagerSettings
- managerSetProxy :: ProxyOverride -> ManagerSettings -> ManagerSettings
- managerSetMaxHeaderLength :: Int -> ManagerSettings -> ManagerSettings
- responseTimeoutMicro :: Int -> ResponseTimeout
- responseTimeoutNone :: ResponseTimeout
- responseTimeoutDefault :: ResponseTimeout
- parseFeed :: MonadCatch m => Text -> m (FeedDefinition, [FeedItem])
- runCallback :: MonadIO m => Handle m -> Callback -> CallbackMessage -> m (Either (Callback, Int, LByteString, LByteString) (Callback, LByteString, LByteString))
- feedC :: MonadCatch m => ConduitT Event o m (Maybe (FeedDefinition, [FeedItem]))
- parseFeedItem :: MonadCatch m => Text -> m FeedItem
- getMainLink :: FeedItem -> Maybe Link
- areSameItem :: FeedItem -> FeedItem -> Bool
- _withGet :: Handle m -> forall a. URI -> (Response (Producer ByteString m ()) -> m a) -> m a
- withGet :: Monad m => Handle m -> Handle m -> URI -> (Response (Producer ByteString m ()) -> m a) -> m a
- parseXml :: Handle m -> URI -> LByteString -> m (FeedDefinition, [FeedItem])
Documentation
External program run for each feed element.
Data is passed to that program through standard input (stdin
).
Callback | |
|
Instances
Generic Callback Source # | |
Read Callback Source # | |
Show Callback Source # | |
FromDhall Callback Source # | |
Defined in Imm.Callback autoWith :: InputNormalizer -> Decoder Callback # | |
Eq Callback Source # | |
Ord Callback Source # | |
Defined in Imm.Callback | |
Pretty Callback Source # | |
Defined in Imm.Callback | |
type Rep Callback Source # | |
Defined in Imm.Callback type Rep Callback = D1 ('MetaData "Callback" "Imm.Callback" "imm-2.1.2.0-D2NMr4mlUE8FsGQYPYqh5Y" 'False) (C1 ('MetaCons "Callback" 'PrefixI 'True) (S1 ('MetaSel ('Just "_executable") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 FilePath) :*: S1 ('MetaSel ('Just "_arguments") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Text]))) |
Define a HTTP proxy, consisting of a hostname and port number.
Proxy | |
|
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
Exception HttpException | |
Defined in Network.HTTP.Client.Types | |
Show HttpException | |
Defined in Network.HTTP.Client.Types showsPrec :: Int -> HttpException -> ShowS # show :: HttpException -> String # showList :: [HttpException] -> ShowS # |
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 getHttpManager :: Manager -> Manager # |
data StreamFileStatus #
Status of streaming a request body from a file.
Since 0.4.9
Instances
Show StreamFileStatus | |
Defined in Network.HTTP.Client.Types showsPrec :: Int -> StreamFileStatus -> ShowS # show :: StreamFileStatus -> String # showList :: [StreamFileStatus] -> ShowS # | |
Eq StreamFileStatus | |
Defined in Network.HTTP.Client.Types (==) :: StreamFileStatus -> StreamFileStatus -> Bool # (/=) :: StreamFileStatus -> StreamFileStatus -> Bool # | |
Ord StreamFileStatus | |
Defined in Network.HTTP.Client.Types compare :: StreamFileStatus -> StreamFileStatus -> Ordering # (<) :: StreamFileStatus -> StreamFileStatus -> Bool # (<=) :: StreamFileStatus -> StreamFileStatus -> Bool # (>) :: StreamFileStatus -> StreamFileStatus -> Bool # (>=) :: StreamFileStatus -> StreamFileStatus -> Bool # max :: StreamFileStatus -> StreamFileStatus -> StreamFileStatus # min :: StreamFileStatus -> StreamFileStatus -> StreamFileStatus # |
class HasHttpManager a where #
getHttpManager :: a -> Manager #
Instances
HasHttpManager Manager | |
Defined in Network.HTTP.Client.Types getHttpManager :: Manager -> Manager # |
data ProxyOverride #
How the HTTP proxy server settings should be discovered.
Since 0.4.7
data ManagerSettings #
Settings for a Manager
. Please use the defaultManagerSettings
function and then modify
individual settings. For more information, see http://www.yesodweb.com/book/settings-types.
Since 0.1.0
A simple representation of the HTTP response.
Since 0.1.0
Instances
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 | |
Functor Response | |
Show body => Show (Response body) | |
data ResponseTimeout #
How to deal with timing out on retrieval of response headers.
Since: http-client-0.5.0
Instances
Show ResponseTimeout | |
Defined in Network.HTTP.Client.Types showsPrec :: Int -> ResponseTimeout -> ShowS # show :: ResponseTimeout -> String # showList :: [ResponseTimeout] -> ShowS # | |
Eq ResponseTimeout | |
Defined in Network.HTTP.Client.Types (==) :: ResponseTimeout -> ResponseTimeout -> Bool # (/=) :: ResponseTimeout -> ResponseTimeout -> Bool # |
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
type GivesPopper a = NeedsPopper a -> IO a #
A function which will provide a Popper
to a NeedsPopper
. This
seemingly convoluted structure allows for creation of request bodies which
allocate scarce resources in an exception safe manner.
Since 0.1.0
type NeedsPopper a = Popper -> IO a #
A function which must be provided with a Popper
.
Since 0.1.0
type Popper = IO ByteString #
A function which generates successive chunks of a request body, provider a single empty bytestring when no more data is available.
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
RequestBodyLBS ByteString | |
RequestBodyBS ByteString | |
RequestBodyBuilder Int64 Builder | |
RequestBodyStream Int64 (GivesPopper ()) | |
RequestBodyStreamChunked (GivesPopper ()) | |
RequestBodyIO (IO RequestBody) | Allows creation of a Since: http-client-0.4.28 |
Instances
IsString RequestBody | Since 0.4.12 |
Defined in Network.HTTP.Client.Types fromString :: String -> RequestBody # | |
Monoid RequestBody | |
Defined in Network.HTTP.Client.Types mempty :: RequestBody # mappend :: RequestBody -> RequestBody -> RequestBody # mconcat :: [RequestBody] -> RequestBody # | |
Semigroup RequestBody | |
Defined in Network.HTTP.Client.Types (<>) :: RequestBody -> RequestBody -> RequestBody # sconcat :: NonEmpty RequestBody -> RequestBody # stimes :: Integral b => b -> RequestBody -> RequestBody # |
data HttpExceptionContent #
StatusCodeException (Response ()) ByteString | Generated by the May include the beginning of the response body. Since: http-client-0.5.0 |
TooManyRedirects [Response ByteString] | The server responded with too many redirects for a request. Contains the list of encountered responses containing redirects in reverse chronological order; including last redirect, which triggered the exception and was not followed. Since: http-client-0.5.0 |
OverlongHeaders | Either too many headers, or too many total bytes in a single header, were returned by the server, and the memory exhaustion protection in this library has kicked in. Since: http-client-0.5.0 |
ResponseTimeout | The server took too long to return a response. This can
be altered via Since: http-client-0.5.0 |
ConnectionTimeout | Attempting to connect to the server timed out. Since: http-client-0.5.0 |
ConnectionFailure SomeException | An exception occurred when trying to connect to the server. Since: http-client-0.5.0 |
InvalidStatusLine ByteString | The status line returned by the server could not be parsed. Since: http-client-0.5.0 |
InvalidHeader ByteString | The given response header line could not be parsed Since: http-client-0.5.0 |
InvalidRequestHeader ByteString | The given request header is not compliant (e.g. has newlines) Since: http-client-0.5.14 |
InternalException SomeException | An exception was raised by an underlying library when performing the request. Most often, this is caused by a failing socket action or a TLS exception. Since: http-client-0.5.0 |
ProxyConnectException ByteString Int Status | A non-200 status code was returned when trying to connect to the proxy server on the given host and port. Since: http-client-0.5.0 |
NoResponseDataReceived | No response data was received from the server at all. This exception may deserve special handling within the library, since it may indicate that a pipelining has been used, and a connection thought to be open was in fact closed. Since: http-client-0.5.0 |
TlsNotSupported | Exception thrown when using a Since: http-client-0.5.0 |
WrongRequestBodyStreamSize Word64 Word64 | The request body provided did not match the expected size. Provides the expected and actual size. Since: http-client-0.4.31 |
ResponseBodyTooShort Word64 Word64 | The returned response body is too short. Provides the expected size and actual size. Since: http-client-0.5.0 |
InvalidChunkHeaders | A chunked response body had invalid headers. Since: http-client-0.5.0 |
IncompleteHeaders | An incomplete set of response headers were returned. Since: http-client-0.5.0 |
InvalidDestinationHost ByteString | The host we tried to connect to is invalid (e.g., an empty string). |
HttpZlibException ZlibException | An exception was thrown when inflating a response body. Since: http-client-0.5.0 |
InvalidProxyEnvironmentVariable Text Text | Values in the proxy environment variable were invalid. Provides the environment variable name and its value. Since: http-client-0.5.0 |
ConnectionClosed | Attempted to use a Since: http-client-0.5.0 |
InvalidProxySettings Text | Proxy settings are not valid (Windows specific currently) @since 0.5.7 |
Instances
Show HttpExceptionContent | |
Defined in Network.HTTP.Client.Types showsPrec :: Int -> HttpExceptionContent -> ShowS # show :: HttpExceptionContent -> String # showList :: [HttpExceptionContent] -> ShowS # |
type BodyReader = IO ByteString #
An IO
action that represents an incoming response body coming from the
server. Data provided by this action has already been gunzipped and
de-chunked, and respects any content-length headers present.
The action gets a single chunk of data from the response body, or an empty bytestring if no more data is available.
Since 0.4.0
data HistoriedResponse body #
A datatype holding information on redirected requests and the final response.
Since 0.4.1
Instances
data CallbackMessage Source #
Data structure passed to the external program, through JSON format.
The data schema is described in file schema/imm.json
, provided with this library.
Instances
data FeedLocation Source #
Feed location identifies a feed. It is either: - the feed URI - a webpage URI that refers to the feed through an alternate link, in which case an optional feed title can be provided to disambiguate multiple such links
Instances
A query describes a set of feeds through some criteria.
newtype FeedDefinition Source #
Instances
FeedItem | |
|
Instances
Author | |
|
Instances
FromJSON Author Source # | |
ToJSON Author Source # | |
Generic Author Source # | |
Show Author Source # | |
Eq Author Source # | |
Ord Author Source # | |
Pretty Author Source # | |
type Rep Author Source # | |
Defined in Imm.Feed type Rep Author = D1 ('MetaData "Author" "Imm.Feed" "imm-2.1.2.0-D2NMr4mlUE8FsGQYPYqh5Y" 'False) (C1 ('MetaCons "Author" 'PrefixI 'True) (S1 ('MetaSel ('Just "_authorName") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text) :*: (S1 ('MetaSel ('Just "_authorEmail") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text) :*: S1 ('MetaSel ('Just "_authorURI") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe AnyURI))))) |
getLogLevel :: Handle m -> m LogLevel Source #
setLogLevel :: Handle m -> LogLevel -> m () Source #
newManager :: ManagerSettings -> IO Manager #
Create a Manager
. The Manager
will be shut down automatically via
garbage collection.
Creating a new Manager
is a relatively expensive operation, you are
advised to share a single Manager
between requests instead.
The first argument to this function is often defaultManagerSettings
,
though add-on libraries may provide a recommended replacement.
Since 0.1.0
equalCookie :: Cookie -> Cookie -> Bool #
equivCookie :: Cookie -> Cookie -> Bool #
Equality of name, domain, path only. This corresponds to step 11 of the algorithm
described in Section 5.3 "Storage Model". See also: equal
.
Since: http-client-0.7.0
compareCookies :: Cookie -> Cookie -> Ordering #
Instead of instance Ord Cookie
. See equalCookie
, equivCookie
.
Since: http-client-0.7.0
equalCookieJar :: CookieJar -> CookieJar -> Bool #
See equalCookie
.
Since: http-client-0.7.0
equivCookieJar :: CookieJar -> CookieJar -> Bool #
See equalCookieJar
, equalCookie
.
Since: http-client-0.7.0
:: IO ByteString | read |
-> (ByteString -> IO ()) | write |
-> IO () | close |
-> IO Connection |
Create a new Connection
from a read, write, and close function.
Since: http-client-0.5.3
:: Socket | |
-> Int | chunk size |
-> IO Connection |
Create a new Connection
from a Socket
.
Since: http-client-0.5.3
strippedHostName :: String -> String #
brRead :: BodyReader -> IO ByteString #
Get a single chunk of data from the response body, or an empty bytestring if no more data is available.
Note that in order to consume the entire request body, you will need to
repeatedly call this function until you receive an empty ByteString
as a
result.
Since 0.1.0
brReadSome :: BodyReader -> Int -> IO ByteString #
Continuously call brRead
, building up a lazy ByteString until a chunk is
constructed that is at least as many bytes as requested.
Since 0.4.20
brConsume :: BodyReader -> IO [ByteString] #
Strictly consume all remaining chunks of data from the stream.
Since 0.1.0
parseUrl :: MonadThrow m => String -> m Request #
Deprecated synonym for parseUrlThrow
. You probably want
parseRequest
or parseRequest_
instead.
Since: http-client-0.1.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
throwErrorStatusCodes :: MonadIO m => Request -> Response BodyReader -> m () #
Throws a StatusCodeException
wrapped in HttpExceptionRequest
,
if the response's status code indicates an error (if it isn't 2xx).
This can be used to implement checkResponse
.
Since: http-client-0.5.13
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.
requestFromURI :: MonadThrow m => URI -> m Request #
This can fail if the given URI
is not absolute, or if the
URI
scheme is not "http"
or "https"
. In these cases the function
will throw an error via MonadThrow
.
This function defaults some of the values in Request
, such as setting method
to
GET
and requestHeaders
to []
.
A Request
created by this function won't cause exceptions on non-2XX
response status codes.
Since: http-client-0.5.12
requestFromURI_ :: URI -> Request #
Same as requestFromURI
, but if the conversion would fail,
throws an impure exception.
Since: http-client-0.5.12
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
applyBasicAuth :: ByteString -> ByteString -> Request -> Request #
Add a Basic Auth header (with the specified user name and password) to the given Request. Ignore error handling:
applyBasicAuth "user" "pass" $ parseRequest_ url
NOTE: The function applyDigestAuth
is provided by the http-client-tls
package instead of this package due to extra dependencies. Please use that
package if you need to use digest authentication.
Since 0.1.0
applyBearerAuth :: ByteString -> Request -> Request #
Add a Bearer Auth header to the given Request
Since: http-client-0.7.6
applyBasicProxyAuth :: ByteString -> ByteString -> Request -> Request #
Add a Proxy-Authorization header (with the specified username and
password) to the given Request
. Ignore error handling:
applyBasicProxyAuth "user" "pass" <$> parseRequest "http://example.org"
Since 0.3.4
urlEncodedBody :: [(ByteString, ByteString)] -> Request -> Request #
Add url-encoded parameters to the Request
.
This sets a new requestBody
, adds a content-type request header and
changes the method
to POST.
Since 0.1.0
setRequestIgnoreStatus :: Request -> Request #
Modify the request so that non-2XX status codes do not generate a runtime
StatusCodeException
.
Since: http-client-0.4.29
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
setQueryString :: [(ByteString, Maybe ByteString)] -> Request -> Request #
Set the query string to the given key/value pairs.
Since 0.3.6
setQueryStringPartialEscape :: [(ByteString, [EscapeItem])] -> Request -> Request #
Set the query string to the given key/value pairs.
Since: http-client-0.5.10
streamFile :: FilePath -> IO RequestBody #
Send a file as the request body.
It is expected that the file size does not change between calling
streamFile
and making any requests using this request body.
Since 0.4.9
observedStreamFile :: (StreamFileStatus -> IO ()) -> FilePath -> IO RequestBody #
Send a file as the request body, while observing streaming progress via
a PopObserver
. Observations are made between reading and sending a chunk.
It is expected that the file size does not change between calling
observedStreamFile
and making any requests using this request body.
Since 0.4.9
getOriginalRequest :: Response a -> Request #
Retrieve the orignal Request
from a Response
Note that the requestBody
is not available and always set to empty.
Since: http-client-0.7.8
rawConnectionModifySocket :: (Socket -> IO ()) -> IO (Maybe HostAddress -> String -> Int -> IO Connection) #
A value for the managerRawConnection
setting, but also allows you to
modify the underlying Socket
to set additional settings. For a motivating
use case, see: https://github.com/snoyberg/http-client/issues/71.
Since 0.3.8
rawConnectionModifySocketSize :: (Socket -> IO ()) -> IO (Int -> Maybe HostAddress -> String -> Int -> IO Connection) #
Same as rawConnectionModifySocket
, but also takes in a chunk size.
Since: http-client-0.5.2
defaultManagerSettings :: ManagerSettings #
Default value for ManagerSettings
.
Note that this value does not have support for SSL/TLS. If you need to
make any https connections, please use the http-client-tls package, which
provides a tlsManagerSettings
value.
Since 0.1.0
closeManager :: Manager -> IO () #
Close all connections in a Manager
.
Note that this doesn't affect currently in-flight connections, meaning you can safely use it without hurting any queries you may have concurrently running.
Since 0.1.0
withManager :: ManagerSettings -> (Manager -> IO a) -> IO a #
Create, use and close a Manager
.
Since 0.2.1
proxyFromRequest :: ProxyOverride #
Get the proxy settings from the Request
itself.
Since 0.4.7
Never connect using a proxy, regardless of the proxy value in the Request
.
Since 0.4.7
useProxy :: Proxy -> ProxyOverride #
Use the given proxy settings, regardless of the proxy value in the Request
.
Since 0.4.7
useProxySecureWithoutConnect :: Proxy -> ProxyOverride #
Send secure requests to the proxy in plain text rather than using CONNECT,
regardless of the value in the Request
.
Since: http-client-0.7.2
:: Maybe Proxy | fallback if no environment set |
-> ProxyOverride |
:: Text | environment variable name |
-> Maybe Proxy | fallback if no environment set |
-> ProxyOverride |
Same as proxyEnvironment
, but instead of default environment variable
names, allows you to set your own name.
Since 0.4.7
defaultProxy :: ProxyOverride #
The default proxy settings for a manager. In particular: if the http_proxy
(or https_proxy
) environment variable is set, use it. Otherwise, use the values in the Request
.
Since 0.4.7
isIpAddress :: ByteString -> Bool #
:: ByteString | Domain to test |
-> ByteString | Domain from a cookie |
-> Bool |
This corresponds to the subcomponent algorithm entitled "Domain Matching" detailed in section 5.1.3
defaultPath :: Request -> ByteString #
This corresponds to the subcomponent algorithm entitled "Paths" detailed in section 5.1.4
pathMatches :: ByteString -> ByteString -> Bool #
This corresponds to the subcomponent algorithm entitled "Path-Match" detailed in section 5.1.4
createCookieJar :: [Cookie] -> CookieJar #
destroyCookieJar :: CookieJar -> [Cookie] #
isPotentiallyTrustworthyOrigin #
:: Bool | True if HTTPS |
-> ByteString | Host |
-> Bool | Whether or not the origin is potentially trustworthy |
Algorithm described in "Secure Contexts", Section 3.1, "Is origin potentially trustworthy?"
Note per RFC6265 section 5.4 user agent is free to define the meaning of "secure" protocol.
See: https://w3c.github.io/webappsec-secure-contexts/#is-origin-trustworthy
:: CookieJar | Input cookie jar |
-> UTCTime | Value that should be used as "now" |
-> CookieJar | Filtered cookie jar |
This corresponds to the eviction algorithm described in Section 5.3 "Storage Model"
:: Request | The request to insert into |
-> CookieJar | Current cookie jar |
-> UTCTime | Value that should be used as "now" |
-> (Request, CookieJar) | (Output request, Updated cookie jar (last-access-time is updated)) |
This applies the computeCookieString
to a given Request
:: Request | Input request |
-> CookieJar | Current cookie jar |
-> UTCTime | Value that should be used as "now" |
-> Bool | Whether or not this request is coming from an "http" source (not javascript or anything like that) |
-> (ByteString, CookieJar) | (Contents of a "Cookie" header, Updated cookie jar (last-access-time is updated)) |
This corresponds to the algorithm described in Section 5.4 "The Cookie Header"
:: Response a | Response received from server |
-> Request | Request which generated the response |
-> UTCTime | Value that should be used as "now" |
-> CookieJar | Current cookie jar |
-> (CookieJar, Response a) | (Updated cookie jar with cookies from the Response, The response stripped of any "Set-Cookie" header) |
This applies receiveSetCookie
to a given Response
:: SetCookie | The |
-> Request | The request that originated the response that yielded the |
-> UTCTime | Value that should be used as "now" |
-> Bool | Whether or not this request is coming from an "http" source (not javascript or anything like that) |
-> CookieJar | Input cookie jar to modify |
-> CookieJar | Updated cookie jar |
This corresponds to the algorithm described in Section 5.3 "Storage Model"
This function consists of calling generateCookie
followed by insertCheckedCookie
.
Use this function if you plan to do both in a row.
generateCookie
and insertCheckedCookie
are only provided for more fine-grained control.
:: Cookie | The |
-> CookieJar | Input cookie jar to modify |
-> Bool | Whether or not this request is coming from an "http" source (not javascript or anything like that) |
-> CookieJar | Updated (or not) cookie jar |
Insert a cookie created by generateCookie into the cookie jar (or not if it shouldn't be allowed in)
:: SetCookie | The |
-> Request | The request that originated the response that yielded the |
-> UTCTime | Value that should be used as "now" |
-> Bool | Whether or not this request is coming from an "http" source (not javascript or anything like that) |
-> Maybe Cookie | The optional output cookie |
Turn a SetCookie into a Cookie, if it is valid
withResponse :: Request -> Manager -> (Response BodyReader -> IO a) -> IO a #
Perform a Request
using a connection acquired from the given Manager
,
and then provide the Response
to the given function. This function is
fully exception safe, guaranteeing that the response will be closed when the
inner function exits. It is defined as:
withResponse req man f = bracket (responseOpen req man) responseClose f
It is recommended that you use this function in place of explicit calls to
responseOpen
and responseClose
.
You will need to use functions such as brRead
to consume the response
body.
Since 0.1.0
httpLbs :: Request -> Manager -> IO (Response ByteString) #
A convenience wrapper around withResponse
which reads in the entire
response body and immediately closes the connection. Note that this function
performs fully strict I/O, and only uses a lazy ByteString in its response
for memory efficiency. If you are anticipating a large response body, you
are encouraged to use withResponse
and brRead
instead.
Since 0.1.0
httpNoBody :: Request -> Manager -> IO (Response ()) #
A convenient wrapper around withResponse
which ignores the response
body. This is useful, for example, when performing a HEAD request.
Since 0.3.2
responseOpen :: Request -> Manager -> IO (Response BodyReader) #
The most low-level function for initiating an HTTP request.
The first argument to this function gives a full specification
on the request: the host to connect to, whether to use SSL,
headers, etc. Please see Request
for full details. The
second argument specifies which Manager
should be used.
This function then returns a Response
with a
BodyReader
. The Response
contains the status code
and headers that were sent back to us, and the
BodyReader
contains the body of the request. Note
that this BodyReader
allows you to have fully
interleaved IO actions during your HTTP download, making it
possible to download very large responses in constant memory.
An important note: the response body returned by this function represents a
live HTTP connection. As such, if you do not use the response body, an open
socket will be retained indefinitely. You must be certain to call
responseClose
on this response to free up resources.
This function automatically performs any necessary redirects, as specified
by the redirectCount
setting.
When implementing a (reverse) proxy using this function or relating functions, it's wise to remove Transfer-Encoding:, Content-Length:, Content-Encoding: and Accept-Encoding: from request and response headers to be relayed.
Since 0.1.0
responseClose :: Response a -> IO () #
Close any open resources associated with the given Response
. In general,
this will either close an active Connection
or return it to the Manager
to be reused.
Since 0.1.0
withConnection :: Request -> Manager -> (Connection -> IO a) -> IO a #
Perform an action using a Connection
acquired from the given Manager
.
You should use this only when you have to read and write interactively through the connection (e.g. connection by the WebSocket protocol).
Since: http-client-0.5.13
responseOpenHistory :: Request -> Manager -> IO (HistoriedResponse BodyReader) #
A variant of responseOpen
which keeps a history of all redirects
performed in the interim, together with the first 1024 bytes of their
response bodies.
Since 0.4.1
withResponseHistory :: Request -> Manager -> (HistoriedResponse BodyReader -> IO a) -> IO a #
A variant of withResponse
which keeps a history of all redirects
performed in the interim, together with the first 1024 bytes of their
response bodies.
Since 0.4.1
managerSetInsecureProxy :: ProxyOverride -> ManagerSettings -> ManagerSettings #
Set the proxy override value, only for HTTP (insecure) connections.
Since 0.4.7
managerSetSecureProxy :: ProxyOverride -> ManagerSettings -> ManagerSettings #
Set the proxy override value, only for HTTPS (secure) connections.
Since 0.4.7
managerSetProxy :: ProxyOverride -> ManagerSettings -> ManagerSettings #
Set the proxy override value, for both HTTP (insecure) and HTTPS (insecure) connections.
Since 0.4.7
responseTimeoutMicro :: Int -> ResponseTimeout #
Specify maximum time in microseconds the retrieval of response headers is allowed to take
Since: http-client-0.5.0
responseTimeoutNone :: ResponseTimeout #
Do not have a response timeout
Since: http-client-0.5.0
responseTimeoutDefault :: ResponseTimeout #
Use the default response timeout
When used on a Request
, means: use the manager's timeout value
When used on a ManagerSettings
, means: default to 30 seconds
Since: http-client-0.5.0
parseFeed :: MonadCatch m => Text -> m (FeedDefinition, [FeedItem]) Source #
runCallback :: MonadIO m => Handle m -> Callback -> CallbackMessage -> m (Either (Callback, Int, LByteString, LByteString) (Callback, LByteString, LByteString)) Source #
feedC :: MonadCatch m => ConduitT Event o m (Maybe (FeedDefinition, [FeedItem])) Source #
Conduit version of parseFeed
parseFeedItem :: MonadCatch m => Text -> m FeedItem Source #
_withGet :: Handle m -> forall a. URI -> (Response (Producer ByteString m ()) -> m a) -> m a Source #
withGet :: Monad m => Handle m -> Handle m -> URI -> (Response (Producer ByteString m ()) -> m a) -> m a Source #
Simple wrapper around _withGet
that also logs the requested URI.
parseXml :: Handle m -> URI -> LByteString -> m (FeedDefinition, [FeedItem]) Source #