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

Just made the minimal amount of changes to get it to work with conduit 0.4. #19

Merged
merged 2 commits into from Apr 11, 2012
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion Aws/Aws.hs
Expand Up @@ -148,7 +148,7 @@ unsafeAwsRef cfg manager metadataRef request = do
logger cfg Debug $ T.pack $ "String to sign: " ++ show (sqStringToSign q)
let httpRequest = queryToHttpRequest q
resp <- runResourceT $ do
HTTP.Response status headers body <- HTTP.http httpRequest manager
HTTP.Response status _ headers body <- HTTP.http httpRequest manager
responseConsumer request metadataRef status headers body
return resp

Expand Down
5 changes: 3 additions & 2 deletions Aws/Query.hs
Expand Up @@ -11,6 +11,7 @@ import qualified Blaze.ByteString.Builder as Blaze
import qualified Data.ByteString as B
import qualified Data.Text as T
import qualified Data.Text.Encoding as T
import qualified Data.Conduit as C
import qualified Network.HTTP.Conduit as HTTP
import qualified Network.HTTP.Types as HTTP

Expand All @@ -28,12 +29,12 @@ data SignedQuery
, sqContentMd5 :: Maybe B.ByteString
, sqAmzHeaders :: HTTP.RequestHeaders
, sqOtherHeaders :: HTTP.RequestHeaders
, sqBody :: Maybe (HTTP.RequestBody IO)
, sqBody :: Maybe (HTTP.RequestBody (C.ResourceT IO))
, sqStringToSign :: B.ByteString
}
--deriving (Show)

queryToHttpRequest :: SignedQuery -> HTTP.Request IO
queryToHttpRequest :: SignedQuery -> HTTP.Request (C.ResourceT IO)
queryToHttpRequest SignedQuery{..}
= HTTP.def {
HTTP.method = httpMethod sqMethod
Expand Down
4 changes: 2 additions & 2 deletions Aws/Response.hs
Expand Up @@ -35,7 +35,7 @@ tellMetadataRef r m = modifyIORef r (`mappend` m)

type HTTPResponseConsumer a = HTTP.Status
-> HTTP.ResponseHeaders
-> Source IO ByteString
-> Source (ResourceT IO) ByteString
-> ResourceT IO a

class ResponseConsumer r a where
Expand All @@ -46,4 +46,4 @@ instance ResponseConsumer r (HTTP.Response L.ByteString) where
type ResponseMetadata (HTTP.Response L.ByteString) = ()
responseConsumer _ _ status headers bufsource = do
chunks <- bufsource $$ CL.consume
return (HTTP.Response status headers $ L.fromChunks chunks)
return (HTTP.Response status HTTP.http11 headers $ L.fromChunks chunks)
5 changes: 3 additions & 2 deletions Aws/S3/Commands/PutObject.hs
Expand Up @@ -20,6 +20,7 @@ import qualified Data.CaseInsensitive as CI
import qualified Data.Text as T
import qualified Data.Text.Encoding as T
import qualified Network.HTTP.Conduit as HTTP
import qualified Data.Conduit as C

data PutObject = PutObject {
poObjectName :: T.Text,
Expand All @@ -32,11 +33,11 @@ data PutObject = PutObject {
poExpires :: Maybe Int,
poAcl :: Maybe CannedAcl,
poStorageClass :: Maybe StorageClass,
poRequestBody :: HTTP.RequestBody IO,
poRequestBody :: HTTP.RequestBody (C.ResourceT IO),
poMetadata :: [(T.Text,T.Text)]
}

putObject :: T.Text -> Bucket -> HTTP.RequestBody IO -> PutObject
putObject :: T.Text -> Bucket -> HTTP.RequestBody (C.ResourceT IO) -> PutObject
putObject obj bucket body = PutObject obj bucket Nothing Nothing Nothing Nothing Nothing Nothing Nothing Nothing body []

data PutObjectResponse
Expand Down
3 changes: 2 additions & 1 deletion Aws/S3/Query.hs
Expand Up @@ -20,6 +20,7 @@ import qualified Data.ByteString as B
import qualified Data.ByteString.Char8 as B8
import qualified Data.CaseInsensitive as CI
import qualified Network.HTTP.Conduit as HTTP
import qualified Data.Conduit as C
import qualified Network.HTTP.Types as HTTP

data S3Query
Expand All @@ -33,7 +34,7 @@ data S3Query
, s3QContentMd5 :: Maybe B.ByteString
, s3QAmzHeaders :: HTTP.RequestHeaders
, s3QOtherHeaders :: HTTP.RequestHeaders
, s3QRequestBody :: Maybe (HTTP.RequestBody IO)
, s3QRequestBody :: Maybe (HTTP.RequestBody (C.ResourceT IO))
}

instance Show S3Query where
Expand Down
4 changes: 2 additions & 2 deletions Aws/S3/Response.hs
Expand Up @@ -51,8 +51,8 @@ s3ErrorResponseConsumer status _headers source
= do doc <- source $$ XML.sinkDoc XML.def
let cursor = Cu.fromDocument doc
liftIO $ case parseError cursor of
Success err -> C.resourceThrow err
Failure otherErr -> C.resourceThrow otherErr
Success err -> C.monadThrow err
Failure otherErr -> C.monadThrow otherErr
where
parseError :: Cu.Cursor -> Attempt S3Error
parseError root = do code <- force "Missing error Code" $ root $/ elContent "Code"
Expand Down
4 changes: 2 additions & 2 deletions Aws/Sqs/Response.hs
Expand Up @@ -42,8 +42,8 @@ sqsErrorResponseConsumer status _headers source
= do doc <- source $$ XML.sinkDoc XML.def
let cursor = Cu.fromDocument doc
liftIO $ case parseError cursor of
Success err -> C.resourceThrow err
Failure otherErr -> C.resourceThrow otherErr
Success err -> C.monadThrow err
Failure otherErr -> C.monadThrow otherErr
where
parseError :: Cu.Cursor -> Attempt SqsError
parseError root = do cursor <- force "Missing Error" $ root $/ Cu.laxElement "Error"
Expand Down
7 changes: 4 additions & 3 deletions Aws/Util.hs
@@ -1,8 +1,9 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE FlexibleContexts #-}

module Aws.Util
where
module Aws.Util where

import Control.Monad.Trans.Control
import Control.Arrow
import Control.Exception
import Data.ByteString.Char8 ({- IsString -})
Expand All @@ -15,7 +16,7 @@ import qualified Data.ByteString as B
import qualified Data.ByteString.UTF8 as BU
import qualified Data.Conduit as C

tryError :: (Exception e, C.ResourceIO m) => m b -> m (Either e b)
tryError :: (Exception e, C.MonadResource m, MonadBaseControl IO m) => m b -> m (Either e b)
tryError = Control.Exception.Lifted.try

queryList :: (a -> [(B.ByteString, B.ByteString)]) -> B.ByteString -> [a] -> [(B.ByteString, B.ByteString)]
Expand Down
2 changes: 1 addition & 1 deletion Aws/Xml.hs
Expand Up @@ -55,5 +55,5 @@ xmlCursorConsumer parse metadataRef _status _headers source
let Response metadata x = parse cursor
liftIO $ tellMetadataRef metadataRef metadata
case x of
Failure err -> liftIO $ C.resourceThrow err
Failure err -> liftIO $ C.monadThrow err
Success v -> return v
7 changes: 4 additions & 3 deletions aws.cabal
Expand Up @@ -136,22 +136,23 @@ Library
bytestring == 0.9.*,
case-insensitive >= 0.2 && < 0.5,
cereal == 0.3.*,
conduit >= 0.2 && < 0.3,
conduit >= 0.4,
Copy link
Collaborator

Choose a reason for hiding this comment

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

There should be an upper bound here, like

                       conduit              >= 0.4     && < 0.5,

crypto-api >= 0.9,
cryptohash >= 0.6 && < 0.8,
directory >= 1.0 && < 1.2,
failure >= 0.1.0.1 && < 0.3,
filepath >= 1.1 && < 1.4,
http-conduit >= 1.2 && < 1.3,
http-conduit >= 1.4,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Here, too.

http-types >= 0.6 && < 0.7,
lifted-base == 0.1.*,
mtl == 2.*,
monad-control >= 0.3,
old-locale == 1.*,
text >= 0.11,
time >= 1.1.4 && < 1.5,
transformers >= 0.2.2.0 && < 0.3,
utf8-string == 0.3.*,
xml-conduit >= 0.5.0
xml-conduit >= 0.7.0

GHC-Options: -Wall

Expand Down