Safe Haskell | None |
---|---|
Language | GHC2021 |
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 :: forall m (n :: Type -> Type) i a. (MonadUnliftIO m, MonadIO n) => Request -> (Response (ConduitM i ByteString n ()) -> m a) -> m a
- setRequestCheckStatus :: Request -> Request
- setRequestMethod :: ByteString -> Request -> Request
- setRequestHeader :: HeaderName -> [ByteString] -> Request -> Request
- setRequestHeaders :: RequestHeaders -> 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
- data HttpExceptionContent
- = StatusCodeException (Response ()) ByteString
- | TooManyRedirects [Response ByteString]
- | OverlongHeaders
- | TooManyHeaderFields
- | 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
- notFound404 :: Status
- hAccept :: HeaderName
- hContentLength :: HeaderName
- hContentMD5 :: HeaderName
- method :: Request -> Method
- methodPost :: Method
- methodPut :: Method
- formDataBody :: MonadIO m => [Part] -> Request -> m Request
- partFileRequestBody :: forall (m :: Type -> Type). Applicative m => Text -> FilePath -> RequestBody -> PartM m
- partBS :: forall (m :: Type -> Type). Applicative m => Text -> ByteString -> PartM m
- partLBS :: forall (m :: Type -> Type). 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
- requestBody :: Request -> RequestBody
- verifiedDownload :: HasTerm env => DownloadRequest -> Path Abs File -> (Maybe Integer -> ConduitM ByteString Void (RIO env) ()) -> RIO env Bool
- verifiedDownloadWithProgress :: HasTerm env => DownloadRequest -> Path Abs File -> Text -> Maybe Int -> RIO env Bool
- data CheckHexDigest
- data DownloadRequest
- drRetryPolicyDefault :: RetryPolicy
- data VerifiedDownloadException
- data HashCheck = (Show a, HashAlgorithm a) => HashCheck {}
- mkDownloadRequest :: Request -> DownloadRequest
- setHashChecks :: [HashCheck] -> DownloadRequest -> DownloadRequest
- setLengthCheck :: Maybe LengthCheck -> DownloadRequest -> DownloadRequest
- setRetryPolicy :: RetryPolicy -> DownloadRequest -> DownloadRequest
- setForceDownload :: Bool -> DownloadRequest -> DownloadRequest
Documentation
httpSink :: MonadUnliftIO m => Request -> (Response () -> ConduitM ByteString Void m a) -> m a Source #
withResponse :: forall m (n :: Type -> Type) i a. (MonadUnliftIO m, MonadIO n) => Request -> (Response (ConduitM i ByteString n ()) -> m a) -> m a Source #
setRequestCheckStatus :: Request -> Request #
setRequestMethod :: ByteString -> Request -> Request #
setRequestHeader :: HeaderName -> [ByteString] -> Request -> Request #
setRequestHeaders :: RequestHeaders -> 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 # | |
Monoid RequestBody | |
Defined in Network.HTTP.Client.Types Methods mempty :: RequestBody # mappend :: RequestBody -> RequestBody -> RequestBody # mconcat :: [RequestBody] -> RequestBody # | |
Semigroup RequestBody | |
Defined in Network.HTTP.Client.Types Methods (<>) :: RequestBody -> RequestBody -> RequestBody # sconcat :: NonEmpty RequestBody -> RequestBody stimes :: Integral b => b -> RequestBody -> RequestBody |
Instances
Foldable Response | |
Defined in Network.HTTP.Client.Types Methods 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 | |
Defined in Network.HTTP.Client.Types | |
Functor Response | |
Show body => Show (Response body) | |
data HttpException #
Instances
Exception HttpException | |
Defined in Network.HTTP.Client.Types Methods toException :: HttpException -> SomeException # fromException :: SomeException -> Maybe HttpException # displayException :: HttpException -> String # | |
Show HttpException | |
Defined in Network.HTTP.Client.Types Methods showsPrec :: Int -> HttpException -> ShowS show :: HttpException -> String # showList :: [HttpException] -> ShowS |
data HttpExceptionContent #
Constructors
Instances
Show HttpExceptionContent | |
Defined in Network.HTTP.Client.Types Methods showsPrec :: Int -> HttpExceptionContent -> ShowS show :: HttpExceptionContent -> String # showList :: [HttpExceptionContent] -> ShowS |
notFound404 :: Status #
hContentLength :: HeaderName #
hContentMD5 :: HeaderName #
methodPost :: Method #
formDataBody :: MonadIO m => [Part] -> Request -> m Request #
partFileRequestBody :: forall (m :: Type -> Type). Applicative m => Text -> FilePath -> RequestBody -> PartM m #
partBS :: forall (m :: Type -> Type). Applicative m => Text -> ByteString -> PartM m #
partLBS :: forall (m :: Type -> Type). 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
requestBody :: Request -> RequestBody #
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.
verifiedDownloadWithProgress :: HasTerm env => DownloadRequest -> Path Abs File -> Text -> Maybe Int -> RIO env Bool Source #
data CheckHexDigest Source #
Constructors
CheckHexDigestString String | |
CheckHexDigestByteString ByteString | |
CheckHexDigestHeader ByteString |
Instances
IsString CheckHexDigest | |
Defined in Network.HTTP.Download.Verified Methods fromString :: String -> CheckHexDigest # | |
Show CheckHexDigest | |
Defined in Network.HTTP.Download.Verified Methods showsPrec :: Int -> CheckHexDigest -> ShowS show :: CheckHexDigest -> String # showList :: [CheckHexDigest] -> ShowS |
data DownloadRequest Source #
A request together with some checks to perform.
Construct using the downloadRequest
smart constructor and associated
setters. The constructor itself is not exposed to avoid breaking changes
with additional fields.
Since: http-download-0.2.0.0
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 VerifiedDownloadException Source #
An exception regarding verification of a download.
Constructors
WrongContentLength Request Int ByteString | |
WrongStreamLength Request Int Int | |
WrongDigest Request String CheckHexDigest String | |
DownloadHttpError HttpException |
Instances
Exception VerifiedDownloadException | |
Defined in Network.HTTP.Download.Verified | |
Show VerifiedDownloadException | |
Defined in Network.HTTP.Download.Verified Methods showsPrec :: Int -> VerifiedDownloadException -> ShowS show :: VerifiedDownloadException -> String # showList :: [VerifiedDownloadException] -> ShowS |
mkDownloadRequest :: Request -> DownloadRequest Source #
Construct a new DownloadRequest
from the given Request
. Use associated
setters to modify the value further.
Since: http-download-0.2.0.0
setHashChecks :: [HashCheck] -> DownloadRequest -> DownloadRequest Source #
Set the hash checks to be run when verifying.
Since: http-download-0.2.0.0
setLengthCheck :: Maybe LengthCheck -> DownloadRequest -> DownloadRequest Source #
Set the length check to be run when verifying.
Since: http-download-0.2.0.0
setRetryPolicy :: RetryPolicy -> DownloadRequest -> DownloadRequest Source #
Set the retry policy to be used when downloading.
Since: http-download-0.2.0.0
setForceDownload :: Bool -> DownloadRequest -> DownloadRequest Source #
If True
, force download even if the file already exists. Useful for
download a resource which may change over time.