on master help sign in
refactoring.
commitdf9cc9857e4420b0a82c89a3701cb0438a0ba955 authorKazu Yamamoto <kazu@iij.ad.jp> dateWed 16 Mar 2016, 14:39 (11 years ago) parent4a8d4d9
2 files changed+17−22
warp/Network/Wai/Handler/Warp/HTTP2/Receiver.hs+17 warp/Network/Wai/Handler/Warp/HTTP2/Request.hs−22
warp/Network/Wai/Handler/Warp/HTTP2/Receiver.hs+17
@@ -347,3 +347,20 @@ stream _ _ _ _ (Open Continued{}) _ = E.throwIO $ ConnectionError ProtocolError
347347stream _ _ _ _ st@(Closed (ResetByMe _)) _ = return st
348348stream FrameData FrameHeader{streamId} _ _ _ _ = E.throwIO $ StreamError StreamClosed streamId
349349stream _ FrameHeader{streamId} _ _ _ _ = E.throwIO $ StreamError ProtocolError streamId
350+
351+----------------------------------------------------------------
352+
353+newReadBody :: TQueue ByteString -> IO (IO ByteString)
354+newReadBody q = do
355+ ref <- newIORef False
356+ return $ readBody q ref
357+
358+readBody :: TQueue ByteString -> IORef Bool -> IO ByteString
359+readBody q ref = do
360+ eof <- readIORef ref
361+ if eof then
362+ return ""
363+ else do
364+ bs <- atomically $ readTQueue q
365+ when (bs == "") $ writeIORef ref True
366+ return bs
warp/Network/Wai/Handler/Warp/HTTP2/Request.hs−22
@@ -3,7 +3,6 @@
33
44module Network.Wai.Handler.Warp.HTTP2.Request (
55 mkRequest
6− , newReadBody
76 , MkReq
87 , ValidHeaders(..)
98 , validateHeaders
@@ -12,13 +11,10 @@ module Network.Wai.Handler.Warp.HTTP2.Request (
1211#if __GLASGOW_HASKELL__ < 709
1312import Control.Applicative ((<$>))
1413#endif
15−import Control.Concurrent.STM
16−import Control.Monad (when)
1714import Data.ByteString (ByteString)
1815import qualified Data.ByteString as BS
1916import qualified Data.ByteString.Char8 as B8
2017import Data.CaseInsensitive (mk)
21−import Data.IORef (IORef, readIORef, newIORef, writeIORef)
2218import Data.Maybe (isJust)
2319import qualified Data.Vault.Lazy as Vault
2420#if __GLASGOW_HASKELL__ < 709
@@ -168,21 +164,3 @@ validateHeaders hs = case pseudo hs emptySpecial of
168164 in [("cookie",v)]
169165 isPseudo "" = False
170166 isPseudo k = BS.head k == _colon
171−
172−
173−----------------------------------------------------------------
174−
175−newReadBody :: TQueue ByteString -> IO (IO ByteString)
176−newReadBody q = do
177− ref <- newIORef False
178− return $ readBody q ref
179−
180−readBody :: TQueue ByteString -> IORef Bool -> IO ByteString
181−readBody q ref = do
182− eof <- readIORef ref
183− if eof then
184− return ""
185− else do
186− bs <- atomically $ readTQueue q
187− when (bs == "") $ writeIORef ref True
188− return bs