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 LByteString)
- httpNoBody :: MonadIO m => Request -> m (Response ())
- httpSink :: MonadUnliftIO m => Request -> (Response () -> ConduitM ByteString Void m a) -> m a
- withResponse :: (MonadUnliftIO m, MonadIO n) => Request -> (Response (ConduitM i ByteString n ()) -> m a) -> m a
- setRequestMethod :: ByteString -> Request -> Request
- setRequestHeader :: HeaderName -> [ByteString] -> Request -> Request
- addRequestHeader :: HeaderName -> ByteString -> Request -> Request
- setRequestBody :: RequestBody -> Request -> Request
- getResponseHeaders :: Response a -> [(HeaderName, ByteString)]
- getResponseBody :: Response a -> a
- getResponseStatusCode :: Response a -> Int
- parseRequest :: MonadThrow m => String -> 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
- = RequestBodyLBS ByteString
- | RequestBodyBS ByteString
- data Response body
- data HttpException
- hAccept :: HeaderName
- hContentLength :: HeaderName
- hContentMD5 :: HeaderName
- methodPut :: Method
- formDataBody :: MonadIO m => [Part] -> Request -> m Request
- partFileRequestBody :: Applicative m => Text -> FilePath -> RequestBody -> PartM m
- partBS :: Applicative m => Text -> ByteString -> PartM m
- partLBS :: Applicative m => Text -> ByteString -> PartM m
- setGithubHeaders :: Request -> Request
- download :: HasTerm env => Request -> Path Abs File -> RIO env Bool
- redownload :: HasTerm env => Request -> Path Abs File -> RIO env Bool
- verifiedDownload :: HasTerm env => DownloadRequest -> Path Abs File -> (Maybe Integer -> ConduitM ByteString Void (RIO env) ()) -> RIO env Bool
- data CheckHexDigest
- data DownloadRequest = DownloadRequest {}
- drRetryPolicyDefault :: RetryPolicy
- data DownloadException
- data HashCheck where
Documentation
httpSink :: MonadUnliftIO m => Request -> (Response () -> ConduitM ByteString Void m a) -> m a Source #
withResponse :: (MonadUnliftIO m, MonadIO n) => Request -> (Response (ConduitM i ByteString n ()) -> m a) -> m a Source #
setRequestMethod :: ByteString -> Request -> Request #
setRequestHeader :: HeaderName -> [ByteString] -> Request -> Request #
addRequestHeader :: HeaderName -> ByteString -> Request -> Request #
setRequestBody :: RequestBody -> Request -> Request #
getResponseHeaders :: Response a -> [(HeaderName, ByteString)] #
getResponseBody :: Response a -> a #
getResponseStatusCode :: Response a -> Int #
parseRequest :: MonadThrow m => String -> m Request #
path :: Request -> ByteString #
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 RequestBody #
Constructors
RequestBodyLBS ByteString | |
RequestBodyBS ByteString |
Instances
IsString RequestBody | |
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 # |
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) | |
data HttpException #
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 # |
hContentLength :: HeaderName #
hContentMD5 :: HeaderName #
formDataBody :: MonadIO m => [Part] -> Request -> m Request #
partFileRequestBody :: Applicative m => Text -> FilePath -> RequestBody -> PartM m #
partBS :: Applicative m => Text -> ByteString -> PartM m #
partLBS :: Applicative m => Text -> ByteString -> PartM m #
setGithubHeaders :: Request -> Request Source #
Set the user-agent request header
Arguments
:: HasTerm env | |
=> Request | |
-> Path Abs File | destination |
-> RIO env Bool | Was a downloaded performed (True) or did the file already exist (False)? |
Download the given URL to the given location. If the file already exists, no download is performed. Otherwise, creates the parent directory, downloads to a temporary file, and on file download completion moves to the appropriate destination.
Throws an exception if things go wrong
Arguments
:: HasTerm env | |
=> DownloadRequest | |
-> Path Abs File | destination |
-> (Maybe Integer -> ConduitM ByteString Void (RIO env) ()) | custom hook to observe progress |
-> RIO env Bool | Whether a download was performed |
Copied and extended version of Network.HTTP.Download.download.
Has the following additional features: * Verifies that response content-length header (if present) matches expected length * Limits the download to (close to) the expected # of bytes * Verifies that the expected # bytes were downloaded (not too few) * Verifies md5 if response includes content-md5 header * Verifies the expected hashes
Throws VerifiedDownloadException. Throws IOExceptions related to file system operations. Throws HttpException.
data CheckHexDigest Source #
Constructors
CheckHexDigestString String | |
CheckHexDigestByteString ByteString | |
CheckHexDigestHeader ByteString |
Instances
Show CheckHexDigest | |
Defined in Network.HTTP.Download.Verified Methods showsPrec :: Int -> CheckHexDigest -> ShowS show :: CheckHexDigest -> String # showList :: [CheckHexDigest] -> ShowS | |
IsString CheckHexDigest | |
Defined in Network.HTTP.Download.Verified Methods fromString :: String -> CheckHexDigest # |
data DownloadRequest Source #
A request together with some checks to perform.
Constructors
DownloadRequest | |
Fields |
drRetryPolicyDefault :: RetryPolicy Source #
Default to retrying seven times with exponential backoff starting from one hundred milliseconds.
This means the tries will occur after these delays if necessary:
- 0.1s
- 0.2s
- 0.4s
- 0.8s
- 1.6s
- 3.2s
- 6.4s
data DownloadException Source #
Constructors
RedownloadInvalidResponse Request (Path Abs File) (Response ()) | |
RedownloadHttpError HttpException |
Instances
Show DownloadException | |
Defined in Network.HTTP.Download Methods showsPrec :: Int -> DownloadException -> ShowS show :: DownloadException -> String # showList :: [DownloadException] -> ShowS | |
Exception DownloadException | |
Defined in Network.HTTP.Download Methods toException :: DownloadException -> SomeException # |
Constructors
HashCheck | |
Fields
|