Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions lib/amazonka-core/src/Amazonka/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,13 @@ requestUnsigned Request {service = Service {..}, ..} r =
end = endpoint r

-- | Specify how a request can be de/serialised.
class (Typeable a, Typeable (AWSResponse a)) => AWSRequest a where
class
( Typeable a,
Typeable (AWSResponse a),
NFData (AWSResponse a)
) =>
AWSRequest a
where
-- | The successful, expected response associated with a request.
type AWSResponse a :: Type

Expand Down Expand Up @@ -952,7 +958,6 @@ pattern TelAviv = Region' "il-central-1"
pattern MexicoCentral :: Region
pattern MexicoCentral = Region' "mx-central-1"


-- Middle East

pattern Bahrain :: Region
Expand Down
17 changes: 13 additions & 4 deletions lib/amazonka/src/Amazonka/Send.hs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ sendEither ::
Env ->
a ->
m (Either Error (AWSResponse a))
sendEither env =
fmap (second Client.responseBody) . HTTP.retryRequest env
sendEither env rq =
HTTP.retryRequest env rq <&> strictResponse
where
strictResponse = forceRight . fmap Client.responseBody

-- | Send a request, returning the associated response if successful.
--
Expand Down Expand Up @@ -59,8 +61,10 @@ sendUnsignedEither ::
Env' withAuth ->
a ->
m (Either Error (AWSResponse a))
sendUnsignedEither env =
fmap (second Client.responseBody) . HTTP.retryRequest (env {auth = Proxy})
sendUnsignedEither env rq =
HTTP.retryRequest (env {auth = Proxy}) rq <&> strictResponse
where
strictResponse = forceRight . fmap Client.responseBody

-- | Make an unsigned request, returning the associated response if successful.
--
Expand Down Expand Up @@ -137,3 +141,8 @@ await env wait =

hoistEither :: (MonadIO m) => Either Error a -> m a
hoistEither = either (liftIO . Exception.throwIO) pure

forceRight :: (NFData b) => Either e b -> Either e b
forceRight = \case
Left e -> Left e
Right b -> rnf b `seq` Right b