module Network.HTTP.Lucu.Interaction
( Interaction(..)
, SomeInteraction(..)
+ , EndOfInteraction(..)
, SyntacticallyInvalidInteraction(..)
, mkSyntacticallyInvalidInteraction
, InteractionQueue
, mkInteractionQueue
- , setResponseStatus
, getCurrentDate
)
where
toInteraction = id
fromInteraction = Just
+-- |'EndOfInteraction' is an 'Interaction' indicating the end of
+-- (possibly pipelined) requests. The connection has already been
+-- closed so no need to reply anything.
+data EndOfInteraction = EndOfInteraction
+ deriving Typeable
+instance Interaction EndOfInteraction
+
-- |'SyntacticallyInvalidInteraction' is an 'Interaction' without even
-- a syntactically valid 'Request'. The response code will always be
-- 'BadRequest'.
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