From aa704596beea9ff60a8e2f28518aa1099ad73436 Mon Sep 17 00:00:00 2001 From: Ben Gamari Date: Sun, 3 Feb 2019 11:17:08 -0500 Subject: [PATCH] client: Parameterize RequestF on request body type This allows us to provide an NFData instance for RequestF, which will later be useful when we capture the request in FailureResponse. --- servant-client-core/CHANGELOG.md | 7 +++++++ .../Servant/Client/Core/Internal/Request.hs | 18 ++++++++++++++---- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/servant-client-core/CHANGELOG.md b/servant-client-core/CHANGELOG.md index 0ff188ce..07cfecda 100644 --- a/servant-client-core/CHANGELOG.md +++ b/servant-client-core/CHANGELOG.md @@ -1,6 +1,13 @@ [The latest version of this document is on GitHub.](https://github.com/haskell-servant/servant/blob/master/servant-client-core/CHANGELOG.md) [Changelog for `servant` package contains significant entries for all core packages.](https://github.com/haskell-servant/servant/blob/master/servant/CHANGELOG.md) +0.15.1 +------ + +- `RequestF` is now parametrized on the request body type as well as the path + type. + + 0.15 ---- diff --git a/servant-client-core/src/Servant/Client/Core/Internal/Request.hs b/servant-client-core/src/Servant/Client/Core/Internal/Request.hs index e90ee0bd..65dc2c89 100644 --- a/servant-client-core/src/Servant/Client/Core/Internal/Request.hs +++ b/servant-client-core/src/Servant/Client/Core/Internal/Request.hs @@ -75,17 +75,27 @@ instance NFData ServantError where rnf (InvalidContentTypeHeader res) = rnf res rnf (ConnectionError err) = rnf err -data RequestF a = Request - { requestPath :: a +data RequestF body path = Request + { requestPath :: path , requestQueryString :: Seq.Seq QueryItem - , requestBody :: Maybe (RequestBody, MediaType) + , requestBody :: Maybe (body, MediaType) , requestAccept :: Seq.Seq MediaType , requestHeaders :: Seq.Seq Header , requestHttpVersion :: HttpVersion , requestMethod :: Method } deriving (Generic, Typeable) -type Request = RequestF Builder.Builder +instance (NFData path, NFData body) => NFData (Request body path) where + rnf r = + rnf (requestPath r) + `seq` rnf (requestQueryString r) + `seq` rnf (requestBody r) + `seq` rnf (requestAccept r) + `seq` rnf (requestHeaders r) + `seq` rnf (requestHttpVersion r) + `seq` rnf (requestMethod r) + +type Request = RequestF RequestBody Builder.Builder -- | The request body. A replica of the @http-client@ @RequestBody@. data RequestBody