--- #hide
module Network.HTTP.Lucu.Postprocess
( postprocess
, completeUnconditionalHeaders
import Network.HTTP.Lucu.RFC1123DateTime
import Network.HTTP.Lucu.Request
import Network.HTTP.Lucu.Response
-import Network.HTTP.Lucu.Utils
import System.Time
{-
postprocess :: Interaction -> STM ()
postprocess itr
- = do reqM <- readItr itr itrRequest id
+ = itr `seq`
+ do reqM <- readItr itr itrRequest id
res <- readItr itr itrResponse id
let sc = resStatus res
where
relyOnRequest :: Interaction -> STM ()
relyOnRequest itr
- = do status <- readItr itr itrResponse resStatus
+ = itr `seq`
+ do status <- readItr itr itrResponse resStatus
req <- readItr itr itrRequest fromJust
let reqVer = reqVersion req
status == ResetContent ||
status == NotModified )
- updateRes itr $ deleteHeader "Content-Length"
- updateRes itr $ deleteHeader "Transfer-Encoding"
+ updateRes itr $! deleteHeader "Content-Length"
+ updateRes itr $! deleteHeader "Transfer-Encoding"
cType <- readHeader itr "Content-Type"
when (cType == Nothing)
if canHaveBody then
when (reqVer == HttpVersion 1 1)
- $ do updateRes itr $ setHeader "Transfer-Encoding" "chunked"
+ $ do updateRes itr $! setHeader "Transfer-Encoding" "chunked"
writeItr itr itrWillChunkBody True
else
-- body 関連のヘッダを削除。但し HEAD なら Content-* は殘す
when (reqMethod req /= HEAD)
- $ do updateRes itr $ deleteHeader "Content-Type"
- updateRes itr $ deleteHeader "Etag"
- updateRes itr $ deleteHeader "Last-Modified"
+ $ do updateRes itr $! deleteHeader "Content-Type"
+ updateRes itr $! deleteHeader "Etag"
+ updateRes itr $! deleteHeader "Last-Modified"
conn <- readHeader itr "Connection"
case fmap (map toLower) conn of
willClose <- readItr itr itrWillClose id
when willClose
- $ updateRes itr $ setHeader "Connection" "close"
+ $ updateRes itr $! setHeader "Connection" "close"
when (reqMethod req == HEAD || not canHaveBody)
$ writeTVar (itrWillDiscardBody itr) True
readHeader :: Interaction -> String -> STM (Maybe String)
readHeader itr name
- = readItr itr itrResponse $ getHeader name
+ = itr `seq` name `seq`
+ readItr itr itrResponse $ getHeader name
updateRes :: Interaction -> (Response -> Response) -> STM ()
updateRes itr updator
- = updateItr itr itrResponse updator
+ = itr `seq` updator `seq`
+ updateItr itr itrResponse updator
completeUnconditionalHeaders :: Config -> Response -> IO Response
completeUnconditionalHeaders conf res
- = return res >>= compServer >>= compDate >>= return
+ = conf `seq` res `seq`
+ return res >>= compServer >>= compDate >>= return
where
compServer res
= case getHeader "Server" res of