on master help sign in
Merge pull request #661 from kosmikus/pr/servant-client-streaming-request-body
eac364eAlp Mestanogullari
servant-client/servant-client.cabal+1−1
@@ -1,5 +1,5 @@
1name: servant-client
1name: servant-client
2−version: 0.9.1.1
2+version: 0.9.2.0
3synopsis: automatical derivation of querying functions for servant webservices
3synopsis: automatical derivation of querying functions for servant webservices
4description:
4description:
5 This library lets you derive automatically Haskell functions that
5 This library lets you derive automatically Haskell functions that
servant-client/src/Servant/Client.hs+1−1
@@ -406,7 +406,7 @@ instance (MimeRender ct a, HasClient api)
406 clientWithRoute Proxy req body =
406 clientWithRoute Proxy req body =
407 clientWithRoute (Proxy :: Proxy api)
407 clientWithRoute (Proxy :: Proxy api)
408 (let ctProxy = Proxy :: Proxy ct
408 (let ctProxy = Proxy :: Proxy ct
409− in setRQBody (mimeRender ctProxy body)
409+ in setReqBodyLBS (mimeRender ctProxy body)
410 -- We use first contentType from the Accept list
410 -- We use first contentType from the Accept list
411 (contentType ctProxy)
411 (contentType ctProxy)
412 req
412 req
servant-client/src/Servant/Common/Req.hs+26−3
@@ -87,7 +87,7 @@ instance Exception ServantError
87data Req = Req
87data Req = Req
88 { reqPath :: String
88 { reqPath :: String
89 , qs :: QueryText
89 , qs :: QueryText
90− , reqBody :: Maybe (ByteString, MediaType)
90+ , reqBody :: Maybe (RequestBody, MediaType)
91 , reqAccept :: [MediaType]
91 , reqAccept :: [MediaType]
92 , headers :: [(String, Text)]
92 , headers :: [(String, Text)]
93 }
93 }
@@ -112,8 +112,31 @@ addHeader name val req = req { headers = headers req
112 ++ [(name, decodeUtf8 (toHeader val))]
112 ++ [(name, decodeUtf8 (toHeader val))]
113 }
113 }
114
114
115+-- | Set body and media type of the request being constructed.
116+--
117+-- The body is set to the given bytestring using the 'RequestBodyLBS'
118+-- constructor.
119+--
120+{-# DEPRECATED setRQBody "Use setReqBodyLBS instead" #-}
115setRQBody :: ByteString -> MediaType -> Req -> Req
121setRQBody :: ByteString -> MediaType -> Req -> Req
122+setRQBody = setReqBodyLBS
123+
124+-- | Set body and media type of the request being constructed.
125+--
126+-- The body is set to the given bytestring using the 'RequestBodyLBS'
127+-- constructor.
128+--
129+-- @since 0.9.2.0
130+--
131+setReqBodyLBS :: ByteString -> MediaType -> Req -> Req
132+setReqBodyLBS b t req = req { reqBody = Just (RequestBodyLBS b, t) }
133+
134+-- | Set body and media type of the request being constructed.
135+--
136+-- @since 0.9.2.0
137+--
138+setReqBody :: RequestBody -> MediaType -> Req -> Req
116−setRQBody b t req = req { reqBody = Just (b, t) }
139+setReqBody b t req = req { reqBody = Just (b, t) }
117
140
118reqToRequest :: (Functor m, MonadThrow m) => Req -> BaseUrl -> m Request
141reqToRequest :: (Functor m, MonadThrow m) => Req -> BaseUrl -> m Request
119reqToRequest req (BaseUrl reqScheme reqHost reqPort path) =
142reqToRequest req (BaseUrl reqScheme reqHost reqPort path) =
@@ -132,7 +155,7 @@ reqToRequest req (BaseUrl reqScheme reqHost reqPort path) =
132
155
133 setrqb r = case reqBody req of
156 setrqb r = case reqBody req of
134 Nothing -> r
157 Nothing -> r
135− Just (b,t) -> r { requestBody = RequestBodyLBS b
158+ Just (b,t) -> r { requestBody = b
136 , requestHeaders = requestHeaders r
159 , requestHeaders = requestHeaders r
137 ++ [(hContentType, cs . show $ t)] }
160 ++ [(hContentType, cs . show $ t)] }
138 setQS = setQueryString $ queryTextToQuery (qs req)
161 setQS = setQueryString $ queryTextToQuery (qs req)