stack-2.1.3.1: The Haskell Tool Stack

Safe HaskellNone
LanguageHaskell2010

Network.HTTP.StackClient

Description

Wrapper functions of Simple and Client to add the 'User-Agent' HTTP request header to each request.

Synopsis

Documentation

withResponse :: (MonadUnliftIO m, MonadIO n) => Request -> (Response (ConduitM i ByteString n ()) -> m a) -> m a Source #

setRequestHeader :: HeaderName -> [ByteString] -> Request -> Request #

getResponseHeaders :: Response a -> [(HeaderName, ByteString)] #

getUri :: Request -> URI #

checkResponse :: Request -> Request -> Response BodyReader -> IO () #

requestHeaders :: Request -> RequestHeaders #

getGlobalManager :: IO Manager #

applyDigestAuth :: (MonadIO m, MonadThrow n) => ByteString -> ByteString -> Request -> Manager -> m (n Request) #

displayDigestAuthException :: DigestAuthException -> String #

data Request #

Instances
Show Request 
Instance details

Defined in Network.HTTP.Client.Types

Methods

showsPrec :: Int -> Request -> ShowS

show :: Request -> String #

showList :: [Request] -> ShowS

data Response body #

Instances
Functor Response 
Instance details

Defined in Network.HTTP.Client.Types

Methods

fmap :: (a -> b) -> Response a -> Response b #

(<$) :: a -> Response b -> Response a #

Foldable Response 
Instance details

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

toList :: Response a -> [a] #

null :: Response a -> Bool #

length :: Response a -> Int #

elem :: Eq a => a -> Response a -> Bool #

maximum :: Ord a => Response a -> a

minimum :: Ord a => Response a -> a

sum :: Num a => Response a -> a #

product :: Num a => Response a -> a #

Traversable Response 
Instance details

Defined in Network.HTTP.Client.Types

Methods

traverse :: Applicative f => (a -> f b) -> Response a -> f (Response b) #

sequenceA :: Applicative f => Response (f a) -> f (Response a) #

mapM :: Monad m => (a -> m b) -> Response a -> m (Response b) #

sequence :: Monad m => Response (m a) -> m (Response a) #

Eq body => Eq (Response body) 
Instance details

Defined in Network.HTTP.Client.Types

Methods

(==) :: Response body -> Response body -> Bool #

(/=) :: Response body -> Response body -> Bool #

Show body => Show (Response body) 
Instance details

Defined in Network.HTTP.Client.Types

Methods

showsPrec :: Int -> Response body -> ShowS

show :: Response body -> String #

showList :: [Response body] -> ShowS

hAccept :: HeaderName #

hContentLength :: HeaderName #

hContentMD5 :: HeaderName #

methodPut :: Method #

formDataBody :: MonadIO m => [Part] -> Request -> m Request #

partBS :: Applicative m => Text -> ByteString -> PartM m #

partLBS :: Applicative m => Text -> ByteString -> PartM m #

setGithubHeaders :: Request -> Request Source #

Set the user-agent request header

download Source #

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

redownload Source #

Arguments

:: HasTerm env 
=> Request 
-> Path Abs File

destination

-> RIO env Bool 

Same as download, but will download a file a second time if it is already present.

Returns True if the file was downloaded, False otherwise

verifiedDownload Source #

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 DownloadRequest Source #

A request together with some checks to perform.

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 HashCheck where Source #

Constructors

HashCheck 

Fields

Instances
Show HashCheck 
Instance details

Defined in Network.HTTP.Download.Verified

Methods

showsPrec :: Int -> HashCheck -> ShowS

show :: HashCheck -> String #

showList :: [HashCheck] -> ShowS