on master help sign in
fromEitherFile -> fromResponseBody
commit8811b6afa8cf874cac6364e91937fe63c3d577da authorMichael Snoyman <michael@snoyman.com> dateThu 8 Jul 2010, 23:42 (16 years ago) parente3154be
1 file changed+9−7
Network/Wai/Enumerator.hs+9−7
Network/Wai/Enumerator.hs+9−7
@@ -14,10 +14,10 @@ module Network.Wai.Enumerator
1414 , fromHandle
1515 -- ** FilePath
1616 , fromFile
17− , fromEitherFile
17+ , fromResponseBody
1818 ) where
1919
20−import Network.Wai (Enumerator (..), Source (..))
20+import Network.Wai (Enumerator (..), Source (..), ResponseBody (..))
2121import qualified Network.Wai.Source as Source
2222import qualified Data.ByteString.Lazy as L
2323import qualified Data.ByteString as B
@@ -110,8 +110,10 @@ fromFile :: FilePath -> Enumerator
110110fromFile fp = Enumerator $ \iter a0 -> withBinaryFile fp ReadMode $ \h ->
111111 runEnumerator (fromHandle h) iter a0
112112
113−-- | Since the response body is defined as an 'Either' 'FilePath' 'Enumerator',
114−-- this function simply reduces the whole operator to an enumerator. This can
115−-- be convenient for server implementations not optimizing file sending.
116−fromEitherFile :: Either FilePath Enumerator -> Enumerator
117−fromEitherFile = either fromFile id
113+-- | Since the response body is defined as a 'ResponseBody', this function
114+-- simply reduces the whole value to an enumerator. This can be convenient for
115+-- server implementations not optimizing file sending.
116+fromResponseBody :: ResponseBody -> Enumerator
117+fromResponseBody (ResponseEnumerator e) = e
118+fromResponseBody (ResponseLBS lbs) = fromLBS lbs
119+fromResponseBody (ResponseFile fp) = fromFile fp