From 2e8821eba6170f98109f9c344a880e9a880303bf Mon Sep 17 00:00:00 2001 From: Oleg Grenrus Date: Fri, 13 Jan 2017 12:41:58 +0200 Subject: [PATCH 1/5] Relax upper bounds --- hackage-repo-tool/hackage-repo-tool.cabal | 4 +-- hackage-root-tool/hackage-root-tool.cabal | 2 +- .../hackage-security-http-client.cabal | 2 +- .../Client/Repository/HttpLib/HttpClient.hs | 31 ++++++++++++++++--- 4 files changed, 30 insertions(+), 9 deletions(-) diff --git a/hackage-repo-tool/hackage-repo-tool.cabal b/hackage-repo-tool/hackage-repo-tool.cabal index 7e4ed2bb..b1d98acd 100644 --- a/hackage-repo-tool/hackage-repo-tool.cabal +++ b/hackage-repo-tool/hackage-repo-tool.cabal @@ -41,9 +41,9 @@ executable hackage-repo-tool build-depends: base >= 4.4 && < 5, Cabal >= 1.12 && < 1.25, bytestring >= 0.9 && < 0.11, - directory >= 1.1 && < 1.3, + directory >= 1.1 && < 1.4, filepath >= 1.2 && < 1.5, - optparse-applicative >= 0.11 && < 0.13, + optparse-applicative >= 0.11 && < 0.14, tar >= 0.4 && < 0.6, time >= 1.2 && < 1.7, unix >= 2.5 && < 2.8, diff --git a/hackage-root-tool/hackage-root-tool.cabal b/hackage-root-tool/hackage-root-tool.cabal index e3eceef2..1bb66ccc 100644 --- a/hackage-root-tool/hackage-root-tool.cabal +++ b/hackage-root-tool/hackage-root-tool.cabal @@ -27,7 +27,7 @@ executable hackage-root-tool main-is: Main.hs build-depends: base >= 4.4 && < 5, filepath >= 1.2 && < 1.5, - optparse-applicative >= 0.11 && < 0.13, + optparse-applicative >= 0.11 && < 0.14, hackage-security >= 0.5 && < 0.6 default-language: Haskell2010 other-extensions: CPP, ScopedTypeVariables, RecordWildCards diff --git a/hackage-security-http-client/hackage-security-http-client.cabal b/hackage-security-http-client/hackage-security-http-client.cabal index 7656c68e..ab786554 100644 --- a/hackage-security-http-client/hackage-security-http-client.cabal +++ b/hackage-security-http-client/hackage-security-http-client.cabal @@ -20,7 +20,7 @@ library build-depends: base >= 4.4, bytestring >= 0.9, data-default-class >= 0.0, - http-client >= 0.4 && < 0.5, + http-client >= 0.4 && < 0.6, http-types >= 0.8, hackage-security >= 0.5 && < 0.6 hs-source-dirs: src diff --git a/hackage-security-http-client/src/Hackage/Security/Client/Repository/HttpLib/HttpClient.hs b/hackage-security-http-client/src/Hackage/Security/Client/Repository/HttpLib/HttpClient.hs index a1fec1e1..80c01ea9 100644 --- a/hackage-security-http-client/src/Hackage/Security/Client/Repository/HttpLib/HttpClient.hs +++ b/hackage-security-http-client/src/Hackage/Security/Client/Repository/HttpLib/HttpClient.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE OverloadedStrings #-} module Hackage.Security.Client.Repository.HttpLib.HttpClient ( withClient @@ -6,8 +7,8 @@ module Hackage.Security.Client.Repository.HttpLib.HttpClient ( ) where import Control.Exception +import Control.Monad (void) import Data.ByteString (ByteString) -import Data.Default.Class (def) import Network.URI import Network.HTTP.Client (Manager) import qualified Data.ByteString as BS @@ -16,6 +17,10 @@ import qualified Network.HTTP.Client as HttpClient import qualified Network.HTTP.Client.Internal as HttpClient import qualified Network.HTTP.Types as HttpClient +#if !MIN_VERSION_http_client(0,4,30) +import Data.Default.Class (def) +#endif + import Hackage.Security.Client hiding (Header) import Hackage.Security.Client.Repository.HttpLib import Hackage.Security.Util.Checked @@ -55,7 +60,11 @@ get :: Throws SomeRemoteError get manager reqHeaders uri callback = wrapCustomEx $ do -- TODO: setUri fails under certain circumstances; in particular, when -- the URI contains URL auth. Not sure if this is a concern. +#if MIN_VERSION_http_client(0,4,30) + request' <- HttpClient.setUri HttpClient.defaultRequest uri +#else request' <- HttpClient.setUri def uri +#endif let request = setRequestHeaders reqHeaders $ request' checkHttpException $ HttpClient.withResponse request manager $ \response -> do @@ -68,7 +77,11 @@ getRange :: Throws SomeRemoteError -> (HttpStatus -> [HttpResponseHeader] -> BodyReader -> IO a) -> IO a getRange manager reqHeaders uri (from, to) callback = wrapCustomEx $ do +#if MIN_VERSION_http_client(0,4,30) + request' <- HttpClient.setUri HttpClient.defaultRequest uri +#else request' <- HttpClient.setUri def uri +#endif let request = setRange from to $ setRequestHeaders reqHeaders $ request' @@ -80,10 +93,18 @@ getRange manager reqHeaders uri (from, to) callback = wrapCustomEx $ do () | HttpClient.responseStatus response == HttpClient.ok200 -> callback HttpStatus200OK (getResponseHeaders response) br _otherwise -> - throwChecked $ HttpClient.StatusCodeException - (HttpClient.responseStatus response) - (HttpClient.responseHeaders response) - (HttpClient.responseCookieJar response) + throwChecked $ +#if MIN_VERSION_http_client(0,5,0) + HttpClient.HttpExceptionRequest request' $ + HttpClient.StatusCodeException + (void response) + BS.empty +#else + HttpClient.StatusCodeException + (HttpClient.responseStatus response) + (HttpClient.responseHeaders response) + (HttpClient.responseCookieJar response) +#endif -- | Wrap custom exceptions -- From bdc0493fc75e960ace78b4558e312b1df8dfb50c Mon Sep 17 00:00:00 2001 From: Oleg Grenrus Date: Fri, 20 Jan 2017 15:39:44 +0200 Subject: [PATCH 2/5] http-client >= 0.5 --- .../hackage-security-http-client.cabal | 2 +- .../Client/Repository/HttpLib/HttpClient.hs | 20 ------------------- 2 files changed, 1 insertion(+), 21 deletions(-) diff --git a/hackage-security-http-client/hackage-security-http-client.cabal b/hackage-security-http-client/hackage-security-http-client.cabal index ab786554..f354bf5c 100644 --- a/hackage-security-http-client/hackage-security-http-client.cabal +++ b/hackage-security-http-client/hackage-security-http-client.cabal @@ -20,7 +20,7 @@ library build-depends: base >= 4.4, bytestring >= 0.9, data-default-class >= 0.0, - http-client >= 0.4 && < 0.6, + http-client >= 0.5 && < 0.6, http-types >= 0.8, hackage-security >= 0.5 && < 0.6 hs-source-dirs: src diff --git a/hackage-security-http-client/src/Hackage/Security/Client/Repository/HttpLib/HttpClient.hs b/hackage-security-http-client/src/Hackage/Security/Client/Repository/HttpLib/HttpClient.hs index 80c01ea9..e8265b6d 100644 --- a/hackage-security-http-client/src/Hackage/Security/Client/Repository/HttpLib/HttpClient.hs +++ b/hackage-security-http-client/src/Hackage/Security/Client/Repository/HttpLib/HttpClient.hs @@ -1,4 +1,3 @@ -{-# LANGUAGE CPP #-} {-# LANGUAGE OverloadedStrings #-} module Hackage.Security.Client.Repository.HttpLib.HttpClient ( withClient @@ -17,10 +16,6 @@ import qualified Network.HTTP.Client as HttpClient import qualified Network.HTTP.Client.Internal as HttpClient import qualified Network.HTTP.Types as HttpClient -#if !MIN_VERSION_http_client(0,4,30) -import Data.Default.Class (def) -#endif - import Hackage.Security.Client hiding (Header) import Hackage.Security.Client.Repository.HttpLib import Hackage.Security.Util.Checked @@ -60,11 +55,7 @@ get :: Throws SomeRemoteError get manager reqHeaders uri callback = wrapCustomEx $ do -- TODO: setUri fails under certain circumstances; in particular, when -- the URI contains URL auth. Not sure if this is a concern. -#if MIN_VERSION_http_client(0,4,30) request' <- HttpClient.setUri HttpClient.defaultRequest uri -#else - request' <- HttpClient.setUri def uri -#endif let request = setRequestHeaders reqHeaders $ request' checkHttpException $ HttpClient.withResponse request manager $ \response -> do @@ -77,11 +68,7 @@ getRange :: Throws SomeRemoteError -> (HttpStatus -> [HttpResponseHeader] -> BodyReader -> IO a) -> IO a getRange manager reqHeaders uri (from, to) callback = wrapCustomEx $ do -#if MIN_VERSION_http_client(0,4,30) request' <- HttpClient.setUri HttpClient.defaultRequest uri -#else - request' <- HttpClient.setUri def uri -#endif let request = setRange from to $ setRequestHeaders reqHeaders $ request' @@ -94,17 +81,10 @@ getRange manager reqHeaders uri (from, to) callback = wrapCustomEx $ do callback HttpStatus200OK (getResponseHeaders response) br _otherwise -> throwChecked $ -#if MIN_VERSION_http_client(0,5,0) HttpClient.HttpExceptionRequest request' $ HttpClient.StatusCodeException (void response) BS.empty -#else - HttpClient.StatusCodeException - (HttpClient.responseStatus response) - (HttpClient.responseHeaders response) - (HttpClient.responseCookieJar response) -#endif -- | Wrap custom exceptions -- From c19c9ec9c1d945aeacb6c1771dfcb4342b19e064 Mon Sep 17 00:00:00 2001 From: Michael Snoyman Date: Fri, 20 Jan 2017 12:03:22 +0200 Subject: [PATCH 3/5] Support for http-client 0.5 --- .../Client/Repository/HttpLib/HttpClient.hs | 17 ++++++++++------- stack.yaml | 15 +++++++-------- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/hackage-security-http-client/src/Hackage/Security/Client/Repository/HttpLib/HttpClient.hs b/hackage-security-http-client/src/Hackage/Security/Client/Repository/HttpLib/HttpClient.hs index e8265b6d..3659309f 100644 --- a/hackage-security-http-client/src/Hackage/Security/Client/Repository/HttpLib/HttpClient.hs +++ b/hackage-security-http-client/src/Hackage/Security/Client/Repository/HttpLib/HttpClient.hs @@ -1,6 +1,7 @@ {-# LANGUAGE OverloadedStrings #-} module Hackage.Security.Client.Repository.HttpLib.HttpClient ( withClient + , makeHttpLib -- ** Re-exports , Manager -- opaque ) where @@ -32,10 +33,7 @@ import qualified Hackage.Security.Util.Lens as Lens withClient :: ProxyConfig HttpClient.Proxy -> (Manager -> HttpLib -> IO a) -> IO a withClient proxyConfig callback = do manager <- HttpClient.newManager (setProxy HttpClient.defaultManagerSettings) - callback manager HttpLib { - httpGet = get manager - , httpGetRange = getRange manager - } + callback manager $ makeHttpLib manager where setProxy = HttpClient.managerSetProxy $ case proxyConfig of @@ -43,6 +41,13 @@ withClient proxyConfig callback = do ProxyConfigUse p -> HttpClient.useProxy p ProxyConfigAuto -> HttpClient.proxyEnvironment Nothing +-- | Create an 'HttpLib' value from a preexisting 'Manager'. +makeHttpLib :: Manager -> HttpLib +makeHttpLib manager = HttpLib + { httpGet = get manager + , httpGetRange = getRange manager + } + {------------------------------------------------------------------------------- Individual methods -------------------------------------------------------------------------------} @@ -82,9 +87,7 @@ getRange manager reqHeaders uri (from, to) callback = wrapCustomEx $ do _otherwise -> throwChecked $ HttpClient.HttpExceptionRequest request' $ - HttpClient.StatusCodeException - (void response) - BS.empty + HttpClient.StatusCodeException (void response) BS.empty -- | Wrap custom exceptions -- diff --git a/stack.yaml b/stack.yaml index 8ef9c093..53cb73e2 100644 --- a/stack.yaml +++ b/stack.yaml @@ -1,13 +1,12 @@ -resolver: lts-3.4 +resolver: lts-7.14 packages: -- hackage-security -- precompute-fileinfo -- hackage-security-http-client - example-client -- hackage-security-curl -- hackage-root-tool - hackage-repo-tool +- hackage-root-tool +- hackage-security - hackage-security-HTTP +- hackage-security-curl +- hackage-security-http-client +- precompute-fileinfo extra-deps: -- ed25519-0.0.2.0 -- zlib-0.6.1.1 +- http-client-0.5.5 From 283d64f7bee94ca5a0ad45bff4d15f4662e533f0 Mon Sep 17 00:00:00 2001 From: Oleg Grenrus Date: Fri, 20 Jan 2017 16:07:31 +0200 Subject: [PATCH 4/5] Refactor, remove ticked request' --- .../Security/Client/Repository/HttpLib/HttpClient.hs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/hackage-security-http-client/src/Hackage/Security/Client/Repository/HttpLib/HttpClient.hs b/hackage-security-http-client/src/Hackage/Security/Client/Repository/HttpLib/HttpClient.hs index 3659309f..544979d7 100644 --- a/hackage-security-http-client/src/Hackage/Security/Client/Repository/HttpLib/HttpClient.hs +++ b/hackage-security-http-client/src/Hackage/Security/Client/Repository/HttpLib/HttpClient.hs @@ -73,10 +73,8 @@ getRange :: Throws SomeRemoteError -> (HttpStatus -> [HttpResponseHeader] -> BodyReader -> IO a) -> IO a getRange manager reqHeaders uri (from, to) callback = wrapCustomEx $ do - request' <- HttpClient.setUri HttpClient.defaultRequest uri - let request = setRange from to - $ setRequestHeaders reqHeaders - $ request' + request <- (setRange from to . setRequestHeaders reqHeaders) + `fmap` HttpClient.setUri HttpClient.defaultRequest uri checkHttpException $ HttpClient.withResponse request manager $ \response -> do let br = wrapCustomEx $ HttpClient.responseBody response case () of @@ -86,7 +84,7 @@ getRange manager reqHeaders uri (from, to) callback = wrapCustomEx $ do callback HttpStatus200OK (getResponseHeaders response) br _otherwise -> throwChecked $ - HttpClient.HttpExceptionRequest request' $ + HttpClient.HttpExceptionRequest request $ HttpClient.StatusCodeException (void response) BS.empty -- | Wrap custom exceptions From 3b320e1fa9a0472be3cdb07069d75c5bcac33322 Mon Sep 17 00:00:00 2001 From: Oleg Grenrus Date: Sat, 21 Jan 2017 14:27:15 +0200 Subject: [PATCH 5/5] Split build job into two parts: - constrained hackage-security - everything together --- .travis.yml | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index a4eecc5b..a01c8851 100644 --- a/.travis.yml +++ b/.travis.yml @@ -51,10 +51,18 @@ script: - for PKG in "${PKGS[@]}"; do cd "$PKG"; cabal sdist --output-directory="../sdists/$PKG" || break; cd ..; done - - cp -v cabal.project sdists/ - cd sdists/ -# build all packages and run testsuite + + # first build just hackage-security with installed constraints, with and without tests. + # silly yaml, seeing : colon + - "echo packages: hackage-security > cabal.project" + - cabal new-build --disable-tests --constraint "directory installed" --constraint "bytestring installed" + - cabal new-build --enable-tests --constraint "directory installed" --constraint "bytestring installed" + - $(find dist-newstyle -type f -executable -name TestSuite | head -n 1) + + # build all packages and run testsuite + - cp -v ../cabal.project ./ - cabal new-build -j1 - - ./dist-newstyle/build/*/ghc-*/hackage-security-*/c/TestSuite/build/TestSuite/TestSuite + - $(find dist-newstyle -type f -executable -name TestSuite | head -n 1) # EOF