git.iko.soy/typeable/servant
on master help sign in
Merge pull request #1197 from sopvop/headers-stream
4edd164Oleg Grenrus
servant-client-core/src/Servant/Client/Core/HasClient.hs+25
@@ -297,6 +297,31 @@ instance {-# OVERLAPPABLE #-}
297 , requestMethod = reflectMethod (Proxy :: Proxy method)
297 , requestMethod = reflectMethod (Proxy :: Proxy method)
298 }
298 }
299
299
300+instance {-# OVERLAPPING #-}
301+ ( RunStreamingClient m, MimeUnrender ct chunk, ReflectMethod method,
302+ FramingUnrender framing, FromSourceIO chunk a,
303+ BuildHeadersTo hs
304+ ) => HasClient m (Stream method status framing ct (Headers hs a)) where
305+
306+ type Client m (Stream method status framing ct (Headers hs a)) = m (Headers hs a)
307+
308+ hoistClientMonad _ _ f ma = f ma
309+
310+ clientWithRoute _pm Proxy req = withStreamingRequest req' $ \gres -> do
311+ let mimeUnrender' = mimeUnrender (Proxy :: Proxy ct) :: BL.ByteString -> Either String chunk
312+ framingUnrender' = framingUnrender (Proxy :: Proxy framing) mimeUnrender'
313+ val = fromSourceIO $ framingUnrender' $ responseBody gres
314+ return $ Headers
315+ { getResponse = val
316+ , getHeadersHList = buildHeadersTo . toList $ responseHeaders gres
317+ }
318+
319+ where
320+ req' = req
321+ { requestAccept = fromList [contentType (Proxy :: Proxy ct)]
322+ , requestMethod = reflectMethod (Proxy :: Proxy method)
323+ }
324+
300-- | If you use a 'Header' in one of your endpoints in your API,
325-- | If you use a 'Header' in one of your endpoints in your API,
301-- the corresponding querying function will automatically take
326-- the corresponding querying function will automatically take
302-- an additional argument of the type specified by your 'Header',
327-- an additional argument of the type specified by your 'Header',