, InteractionQueue
, mkInteractionQueue
- , setResponseStatus
, getCurrentDate
)
where
mkInteractionQueue ∷ IO InteractionQueue
mkInteractionQueue = newTVarIO (∅)
--- FIXME: Response.hs should provide setStatus ∷ sc → Response → Response
-setResponseStatus ∷ StatusCode sc ⇒ NormalInteraction → sc → STM ()
-setResponseStatus (NI {..}) sc
- = do res ← readTVar niResponse
- let res' = res {
- resStatus = fromStatusCode sc
- }
- writeTVar niResponse res'
-
getCurrentDate ∷ IO Ascii
getCurrentDate = HTTP.toAscii <$> getCurrentTime
$ do state ← readTVar $ niState ni
when (state > DecidingHeader)
$ fail "Too late to declare the response status."
- setResponseStatus ni sc
+ res ← readTVar $ niResponse ni
+ writeTVar (niResponse ni) $ setStatusCode sc res
-- |@'setHeader' name value@ declares the value of the response header
-- @name@ as @value@. Note that this function is not intended to be
-- * Functions
, emptyResponse
+ , setStatusCode
, resCanHaveBody
, printStatusCode
, printResponse
, resHeaders = (∅)
}
+-- |@'setStatusCode' sc res@ sets the status code of @res@ to @sc@.
+setStatusCode ∷ StatusCode sc ⇒ sc → Response → Response
+setStatusCode sc res
+ = res {
+ resStatus = fromStatusCode sc
+ }
+
-- |Returns 'True' iff a given 'Response' allows the existence of
-- response entity body.
resCanHaveBody ∷ Response → Bool