-
Notifications
You must be signed in to change notification settings - Fork 107
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
Conversation
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.
773d836
to
bb17322
Compare
bb17322
to
f18b362
Compare
There was a problem hiding this 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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
Thanks for the review! |
@bgamari thanks for doing this! |
Can we release a new version of |
@bgamari also has release privileges, but I have some time today to try to make a release. |
Yes pretty please with sugar on top! |
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.