add compat cruft for old versions of http-types and http-conduit
This commit is contained in:
parent
5f749a0665
commit
8b15af309a
1 changed files with 20 additions and 2 deletions
|
@ -7,6 +7,7 @@
|
||||||
|
|
||||||
{-# LANGUAGE CPP #-}
|
{-# LANGUAGE CPP #-}
|
||||||
{-# LANGUAGE OverloadedStrings #-}
|
{-# LANGUAGE OverloadedStrings #-}
|
||||||
|
{-# LANGUAGE RankNTypes #-}
|
||||||
|
|
||||||
module Utility.Url (
|
module Utility.Url (
|
||||||
URLString,
|
URLString,
|
||||||
|
@ -42,7 +43,11 @@ data UrlOptions = UrlOptions
|
||||||
{ userAgent :: Maybe UserAgent
|
{ userAgent :: Maybe UserAgent
|
||||||
, reqHeaders :: Headers
|
, reqHeaders :: Headers
|
||||||
, reqParams :: [CommandParam]
|
, reqParams :: [CommandParam]
|
||||||
|
#if MIN_VERSION_http_conduit(2,0,0)
|
||||||
, applyRequest :: Request -> Request
|
, applyRequest :: Request -> Request
|
||||||
|
#else
|
||||||
|
, applyRequest :: forall m. Request m -> Request m
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
instance Default UrlOptions
|
instance Default UrlOptions
|
||||||
|
@ -142,7 +147,11 @@ exists url uo = case parseURIRelaxed url of
|
||||||
liftIO $ closeManager mgr
|
liftIO $ closeManager mgr
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
#if MIN_VERSION_http_conduit(2,0,0)
|
||||||
headRequest :: Request -> Request
|
headRequest :: Request -> Request
|
||||||
|
#else
|
||||||
|
headRequest :: Request m -> Request m
|
||||||
|
#endif
|
||||||
headRequest r = r
|
headRequest r = r
|
||||||
{ method = methodHead
|
{ method = methodHead
|
||||||
-- remove defaut Accept-Encoding header, to get actual,
|
-- remove defaut Accept-Encoding header, to get actual,
|
||||||
|
@ -151,8 +160,6 @@ headRequest r = r
|
||||||
filter (\(h, _) -> h /= hAcceptEncoding)
|
filter (\(h, _) -> h /= hAcceptEncoding)
|
||||||
(requestHeaders r)
|
(requestHeaders r)
|
||||||
}
|
}
|
||||||
where
|
|
||||||
hAcceptEncoding = "Accept-Encoding"
|
|
||||||
|
|
||||||
{- Used to download large files, such as the contents of keys.
|
{- Used to download large files, such as the contents of keys.
|
||||||
-
|
-
|
||||||
|
@ -206,3 +213,14 @@ download' quiet url file uo =
|
||||||
{- Allows for spaces and other stuff in urls, properly escaping them. -}
|
{- Allows for spaces and other stuff in urls, properly escaping them. -}
|
||||||
parseURIRelaxed :: URLString -> Maybe URI
|
parseURIRelaxed :: URLString -> Maybe URI
|
||||||
parseURIRelaxed = parseURI . escapeURIString isAllowedInURI
|
parseURIRelaxed = parseURI . escapeURIString isAllowedInURI
|
||||||
|
|
||||||
|
hAcceptEncoding :: CI.CI B.ByteString
|
||||||
|
hAcceptEncoding = "Accept-Encoding"
|
||||||
|
|
||||||
|
#if ! MIN_VERSION_http_types(0,7,0)
|
||||||
|
hContentLength :: CI.CI B.ByteString
|
||||||
|
hContentLength = "Content-Length"
|
||||||
|
|
||||||
|
hUserAgent :: CI.CI B.ByteString
|
||||||
|
hUserAgent = "User-Agent"
|
||||||
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue