Skip to content

Commit

Permalink
Merge pull request #179 from phadej/bounds
Browse files Browse the repository at this point in the history
Relax upper bounds to allow new major versions of `optparse-applicative`, `directory`, and `http-client`
  • Loading branch information
hvr authored Jan 28, 2017
2 parents fa5fee7 + 3b320e1 commit 42dc8f3
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 29 deletions.
14 changes: 11 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions hackage-repo-tool/hackage-repo-tool.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion hackage-root-tool/hackage-root-tool.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.5 && < 0.6,
http-types >= 0.8,
hackage-security >= 0.5 && < 0.6
hs-source-dirs: src
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
{-# LANGUAGE OverloadedStrings #-}
module Hackage.Security.Client.Repository.HttpLib.HttpClient (
withClient
, makeHttpLib
-- ** Re-exports
, Manager -- opaque
) 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
Expand All @@ -32,17 +33,21 @@ 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
ProxyConfigNone -> HttpClient.noProxy
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
-------------------------------------------------------------------------------}
Expand All @@ -55,7 +60,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.
request' <- HttpClient.setUri def uri
request' <- HttpClient.setUri HttpClient.defaultRequest uri
let request = setRequestHeaders reqHeaders
$ request'
checkHttpException $ HttpClient.withResponse request manager $ \response -> do
Expand All @@ -68,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 def 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
Expand All @@ -80,10 +83,9 @@ 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 $
HttpClient.HttpExceptionRequest request $
HttpClient.StatusCodeException (void response) BS.empty

-- | Wrap custom exceptions
--
Expand Down
15 changes: 7 additions & 8 deletions stack.yaml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 42dc8f3

Please sign in to comment.