@@ -48,7 +48,7 @@ import Data.Text.Lazy.Builder (Builder)
4848import qualified Data.Text.Lazy.Builder as Build
4949import GHC.Generics
5050import GHC.TypeLits
51−import Network.HTTP.Client (HttpException)
51+import Network.HTTP.Client (HttpException, RequestBody (..))
5252import Network.HTTP.Media hiding (Accept)
5353import Network.HTTP.Types hiding (Header)
5454import qualified Network.HTTP.Types as HTTP
@@ -83,8 +83,7 @@ instance ToJSON OAuthToken where
8383
8484newtype Download a = Download a
8585
86−_Download :: Iso' (Download a) a
87−_Download = iso (\(Download x) -> x) Download
86+data Upload a = Upload a RequestBody
8887
8988_Coerce :: (Coercible a b, Coercible b a) => Iso' a b
9089_Coerce = iso coerce coerce
@@ -97,7 +96,6 @@ _Default = iso f Just
9796 f (Just x) = x
9897 f Nothing = mempty
9998
100−type Body = Source IO ByteString
10199type Stream = ResumableSource (ResourceT IO) ByteString
102100
103101newtype ClientId = ClientId { clientIdToText :: Text }
@@ -167,30 +165,23 @@ instance AsError Error where
167165data Service = Service
168166 { _svcId :: !ServiceId
169167 , _svcHost :: !ByteString
170− , _svcPath :: !Builder
171168 , _svcPort :: !Int
172169 , _svcSecure :: !Bool
173170 , _svcTimeout :: !(Maybe Seconds)
174− , _svcScopes :: ![OAuthScope]
175171 }
176172
177−defaultService :: ServiceId -> ByteString -> Builder -> Service
178−defaultService i h p = Service
173+defaultService :: ServiceId -> ByteString -> Service
174+defaultService i h = Service
179175 { _svcId = i
180176 , _svcHost = h
181− , _svcPath = p
182177 , _svcPort = 443
183178 , _svcSecure = True
184179 , _svcTimeout = Just 70
185− , _svcScopes = []
186180 }
187181
188182serviceHost :: Lens' Service ByteString
189183serviceHost = lens _svcHost (\s a -> s { _svcHost = a })
190184
191−servicePath :: Lens' Service Builder
192−servicePath = lens _svcPath (\s a -> s { _svcPath = a })
193−
194185servicePort :: Lens' Service Int
195186servicePort = lens _svcPort (\s a -> s { _svcPort = a })
196187
@@ -201,10 +192,10 @@ serviceTimeout :: Lens' Service (Maybe Seconds)
201192serviceTimeout = lens _svcTimeout (\s a -> s { _svcTimeout = a })
202193
203194-- | A single part of a multipart message.
204−data Part = Part MediaType [(HeaderName, ByteString)] Body
195+data Part = Part MediaType [(HeaderName, ByteString)] RequestBody
205196
206197data Payload
207− = Body !MediaType !Body
198+ = Body !MediaType !RequestBody
208199 | Related ![Part]
209200
210201-- | An intermediary request builder.
@@ -221,7 +212,7 @@ instance Monoid Request where
221212 (_rqPath a <> "/" <> _rqPath b)
222213 (_rqQuery a <> _rqQuery b)
223214 (_rqHeaders a <> _rqHeaders b)
224− (_rqBody b <|> _rqBody a)
215+ (_rqBody b <|> _rqBody a)
225216
226217appendPath :: Request -> Builder -> Request
227218appendPath rq x = rq { _rqPath = _rqPath rq <> "/" <> x }
@@ -240,7 +231,7 @@ appendHeader rq k (Just v) = rq
240231 { _rqHeaders = DList.snoc (_rqHeaders rq) (k, Text.encodeUtf8 v)
241232 }
242233
243−setBody :: Request -> MediaType -> Body -> Request
234+setBody :: Request -> MediaType -> RequestBody -> Request
244235setBody rq c x = rq { _rqBody = Just (Body c x) }
245236
246237setRelated :: Request -> [Part] -> Request
@@ -282,25 +273,25 @@ client f cs m ns rq s = Client
282273 }
283274
284275class Accept c => ToBody c a where
285− toBody :: Proxy c -> a -> Body
276+ toBody :: Proxy c -> a -> RequestBody
286277
287−instance ToBody OctetStream Body where
278+instance ToBody OctetStream RequestBody where
288279 toBody Proxy = id
289280
290281instance ToBody OctetStream ByteString where
291− toBody Proxy = CL.sourceList . (:[])
282+ toBody Proxy = RequestBodyBS
292283
293284instance ToBody OctetStream LBS.ByteString where
294− toBody Proxy = CL.sourceList . LBS.toChunks
285+ toBody Proxy = RequestBodyLBS
295286
296287instance ToBody PlainText ByteString where
297− toBody Proxy = CL.sourceList . (:[])
288+ toBody Proxy = RequestBodyBS
298289
299290instance ToBody PlainText LBS.ByteString where
300− toBody Proxy = CL.sourceList . LBS.toChunks
291+ toBody Proxy = RequestBodyLBS
301292
302293instance ToJSON a => ToBody JSON a where
303− toBody Proxy = CL.sourceList . LBS.toChunks . encode
294+ toBody Proxy = RequestBodyLBS . encode
304295
305296class Accept c => FromStream c a where
306297 fromStream :: Proxy c -> Stream -> ResourceT IO (Either String a)