import Data.Sequence (ViewR(..))
import Network.HTTP.Lucu.Config
import Network.HTTP.Lucu.Format
+import Network.HTTP.Lucu.Headers
import Network.HTTP.Lucu.HttpVersion
import Network.HTTP.Lucu.Interaction
import Network.HTTP.Lucu.Postprocess
where
awaitSomethingToWrite :: IO ()
awaitSomethingToWrite
- = do action
+ = {-# SCC "awaitSomethingToWrite" #-}
+ do action
<- atomically $!
do -- キューが空でなくなるまで待つ
queue <- readTVar tQueue
writeContinueIfNecessary :: Interaction -> STM (IO ())
writeContinueIfNecessary itr
- = itr `seq`
+ = {-# SCC "writeContinueIfNecessary" #-}
+ itr `seq`
do expectedContinue <- readItr itr itrExpectedContinue id
if expectedContinue then
do wroteContinue <- readItr itr itrWroteContinue id
-- れば、ヘッダを出力する。ヘッダ出力後であり、bodyToSend が
-- 空でなければ、それを出力する。空である時は、もし状態が
-- Done であれば後処理をする。
- = itr `seq`
+ = {-# SCC "writeHeaderOrBodyIfNecessary" #-}
+ itr `seq`
do wroteHeader <- readItr itr itrWroteHeader id
if not wroteHeader then
- return $ writeHeader itr
+ return $! writeHeader itr
else
do bodyToSend <- readItr itr itrBodyToSend id
writeContinue :: Interaction -> IO ()
writeContinue itr
- = itr `seq`
+ = {-# SCC "writeContinue" #-}
+ itr `seq`
do let cont = Response {
resVersion = HttpVersion 1 1
, resStatus = Continue
- , resHeaders = []
+ , resHeaders = emptyHeaders
}
cont' <- completeUnconditionalHeaders cnf cont
hPutResponse h cont'
writeHeader :: Interaction -> IO ()
writeHeader itr
- = itr `seq`
+ = {-# SCC "writeHeader" #-}
+ itr `seq`
do res <- atomically $! do writeItr itr itrWroteHeader True
readItr itr itrResponse id
hPutResponse h res
writeBodyChunk :: Interaction -> IO ()
writeBodyChunk itr
- = itr `seq`
+ = {-# SCC "writeBodyChunk" #-}
+ itr `seq`
do willDiscardBody <- atomically $! readItr itr itrWillDiscardBody id
willChunkBody <- atomically $! readItr itr itrWillChunkBody id
chunk <- atomically $! do chunk <- readItr itr itrBodyToSend id
finishBodyChunk :: Interaction -> IO ()
finishBodyChunk itr
- = itr `seq`
+ = {-# SCC "finishBodyChunk" #-}
+ itr `seq`
do willDiscardBody <- atomically $! readItr itr itrWillDiscardBody id
willChunkBody <- atomically $! readItr itr itrWillChunkBody id
when (not willDiscardBody && willChunkBody)
finalize :: Interaction -> IO ()
finalize itr
- = itr `seq`
+ = {-# SCC "finalize" #-}
+ itr `seq`
do finishBodyChunk itr
willClose <- atomically $!
do queue <- readTVar tQueue