Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support http-client == 2.2 #213

Merged
merged 8 commits into from
Nov 8, 2016
Merged

Conversation

bgamari
Copy link
Collaborator

@bgamari bgamari commented Nov 4, 2016

This adds support for the http-client-2.2 series, at long last resolving #206. In addition it performs a number of clean-ups throughout the code-base.

This is potentially needed for error handling as HttpException now
includes it.
These include,
  * Redundant imports
  * Defaulting warnings
  * Duplicate exports
This allows us to easily silence a number of redundant import warnings
and drop some CPP.
Copy link
Owner

@aristidb aristidb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My comments are mostly questions for things I don't understand

@@ -52,6 +52,7 @@ import qualified Data.Text.Encoding as T
import qualified Data.Text.IO as T
import qualified Network.HTTP.Conduit as HTTP
import System.IO (stderr)
import Prelude
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this required? I thought Prelude is always implicitly imported?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The import of Control.Applicative is unnecessary with newer base versions, so moving the Prelude import silences the resulting warning in a backwards-compatible way. Edward Kmett introduced me to this trick.

simpleAws cfg scfg request
= liftIO $ HTTP.withManager $ \manager ->
loadToMemory =<< readResponseIO =<< aws cfg scfg manager request
simpleAws cfg scfg request = liftIO $ runResourceT $ do
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did quite like the convenience of withManager. Shame that it's gone.

@@ -111,8 +112,10 @@ import qualified Data.ByteString.UTF8 as BU
import Data.Char
import Data.Conduit (($$+-))
import qualified Data.Conduit as C
#if MIN_VERSION_http_conduit(2,2,0)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, do we still support http-conduit < 2.2 after all these changes?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do.

@@ -130,14 +133,13 @@ import qualified Network.HTTP.Types as HTTP
import System.Directory
import System.Environment
import System.FilePath ((</>))
#if MIN_VERSION_time(1,5,0)
import Data.Time.Format
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was Data.Time.Format an unused import?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes.

loadCredentialsFromInstanceMetadata = liftIO $ HTTP.withManager $ \mgr ->
do
loadCredentialsFromInstanceMetadata = do
mgr <- liftIO $ HTTP.newManager HTTP.tlsManagerSettings
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this manager cleaned up after the call to loadCredentialsFromInstanceMetadata? I may be confused about how http-client / http-conduit work nowadays, so please forgive me if this is a stupid question.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. To quote the documentation of newManager,

Create a Manager. The Manager will be shut down automatically via garbage collection.

-> ResourceT IO a
#if MIN_VERSION_http_conduit(2,2,0)
throwStatusCodeException req resp = do
let resp' = fmap (const ()) resp
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this take the response and strip out the body so it's safe to pass around?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It makes the types line up, yes.

@@ -399,7 +399,7 @@ instance DynVal UTCTime where

-------------------------------------------------------------------------------
pico :: Rational
pico = toRational $ 10 ^ (12 :: Integer)
pico = toRational $ (10 :: Integer) ^ (12 :: Integer)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, that was generating a lot of warnings! :D

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed; ^ is terrible in this respect.

@@ -1338,7 +1339,7 @@ getAttr k m = do
-- | Parse attribute if it's present in the 'Item'. Fail if attribute
-- is present but conversion fails.
getAttr'
:: forall a. (Typeable a, DynVal a)
:: forall a. (DynVal a)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was Typeable never required, or newly not?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Never required.

@@ -139,7 +139,7 @@ Library
scientific >= 0.3,
tagged >= 0.7 && < 0.9,
text >= 0.11,
time >= 1.1.4 && < 2.0,
time >= 1.4.0 && < 1.7,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which ghc version has time 1.4? I wonder if we might go further and make this time 1.5+ only. Also, why the tightening of the upper bound?

Copy link
Collaborator Author

@bgamari bgamari Nov 7, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GHC 7.4.1 through 7.8.4 shipped with 1.4.*. See https://ghc.haskell.org/trac/ghc/wiki/Commentary/Libraries/VersionHistory

@bgamari
Copy link
Collaborator Author

bgamari commented Nov 7, 2016

Thanks for the review!

@aristidb aristidb merged commit 3a04e95 into aristidb:master Nov 8, 2016
@ilovezfs
Copy link

@bgamari thanks for doing this!

@mrkkrp
Copy link

mrkkrp commented Dec 14, 2016

Can we release a new version of aws with this change?

@aristidb
Copy link
Owner

@bgamari also has release privileges, but I have some time today to try to make a release.

@ilovezfs
Copy link

Yes pretty please with sugar on top!

@aristidb
Copy link
Owner

@mrkkrp @ilovezfs 0.15 is released.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants