@@ -180,7 +180,7 @@ processState (Open _ (NoBody tbl@(_, reqvt))) ctx@Context{..} strm@Stream{stream
180
180
streamId
181
181
" no body but content-length is not zero"
182
182
tlr <- newIORef Nothing
183
- let inpObj = InpObj tbl (Just 0 ) (return " " ) tlr
183
+ let inpObj = InpObj tbl (Just 0 ) (return ( mempty , True ) ) tlr
184
184
if isServer ctx
185
185
then do
186
186
let si = toServerInfo roleInfo
@@ -441,7 +441,7 @@ stream FrameHeaders header@FrameHeader{flags, streamId} bs ctx (Open _ (Body q _
441
441
then do
442
442
tbl <- hpackDecodeTrailer frag streamId ctx
443
443
writeIORef tlr (Just tbl)
444
- atomically $ writeTQueue q $ Right " "
444
+ atomically $ writeTQueue q $ Right ( mempty , True )
445
445
return HalfClosedRemote
446
446
else -- we don't support continuation here.
447
447
E. throwIO $
@@ -486,7 +486,7 @@ stream
486
486
E. throwIO $ ConnectionErrorIsSent EnhanceYourCalm streamId " too many empty data"
487
487
else do
488
488
writeIORef bodyLength len
489
- atomically $ writeTQueue q $ Right body
489
+ atomically $ writeTQueue q $ Right ( body, endOfStream)
490
490
if endOfStream
491
491
then do
492
492
case mcl of
@@ -499,7 +499,7 @@ stream
499
499
streamId
500
500
" actual body length is not the same as content-length"
501
501
-- no trailers
502
- atomically $ writeTQueue q $ Right " "
502
+ atomically $ writeTQueue q $ Right ( mempty , True )
503
503
return HalfClosedRemote
504
504
else return s
505
505
@@ -615,26 +615,26 @@ stream x FrameHeader{streamId} _ _ _ _ =
615
615
data Source
616
616
= Source
617
617
(Int -> IO () )
618
- (TQueue (Either E. SomeException ByteString ))
618
+ (TQueue (Either E. SomeException ( ByteString , Bool ) ))
619
619
(IORef ByteString )
620
620
(IORef Bool )
621
621
622
622
mkSource
623
- :: TQueue (Either E. SomeException ByteString ) -> (Int -> IO () ) -> IO Source
623
+ :: TQueue (Either E. SomeException ( ByteString , Bool ) ) -> (Int -> IO () ) -> IO Source
624
624
mkSource q inform = Source inform q <$> newIORef " " <*> newIORef False
625
625
626
- readSource :: Source -> IO ByteString
626
+ readSource :: Source -> IO ( ByteString , Bool )
627
627
readSource (Source inform q refBS refEOF) = do
628
628
eof <- readIORef refEOF
629
629
if eof
630
- then return " "
630
+ then return ( mempty , True )
631
631
else do
632
- bs <- readBS
632
+ (bs, isEOF) <- readBS
633
633
let len = BS. length bs
634
634
inform len
635
- return bs
635
+ return (bs, isEOF)
636
636
where
637
- readBS :: IO ByteString
637
+ readBS :: IO ( ByteString , Bool )
638
638
readBS = do
639
639
bs0 <- readIORef refBS
640
640
if bs0 == " "
@@ -644,9 +644,9 @@ readSource (Source inform q refBS refEOF) = do
644
644
Left err -> do
645
645
writeIORef refEOF True
646
646
E. throwIO err
647
- Right bs -> do
648
- when (bs == " " ) $ writeIORef refEOF True
649
- return bs
647
+ Right (bs, isEOF) -> do
648
+ writeIORef refEOF isEOF
649
+ return (bs, isEOF)
650
650
else do
651
651
writeIORef refBS " "
652
- return bs0
652
+ return ( bs0, False )
0 commit comments