, InteractionQueue
, newInteractionQueue
, newInteraction
- , defaultPageContentType
, setResponseStatus
)
where
import Blaze.ByteString.Builder (Builder)
import Control.Concurrent.STM
-import Data.Ascii (Ascii)
import qualified Data.ByteString as BS
+import Data.Monoid.Unicode
import Data.Sequence (Seq)
import qualified Data.Sequence as S
import Data.Text (Text)
import Network.Socket
import Network.HTTP.Lucu.Config
-import Network.HTTP.Lucu.Headers
import Network.HTTP.Lucu.HttpVersion
import Network.HTTP.Lucu.Preprocess
import Network.HTTP.Lucu.Request
, itrWillChunkBody ∷ !(TVar Bool)
, itrWillDiscardBody ∷ !(TVar Bool)
, itrWillClose ∷ !(TVar Bool)
+ , itrResponseHasCType ∷ !(TVar Bool)
, itrBodyToSend ∷ !(TMVar Builder)
- , itrSentNoBodySoFar ∷ !(TVar Bool)
, itrState ∷ !(TVar InteractionState)
}
newInteractionQueue ∷ IO InteractionQueue
newInteractionQueue = newTVarIO S.empty
-defaultPageContentType ∷ Ascii
-defaultPageContentType = "application/xhtml+xml"
-
newInteraction ∷ Config
→ PortNumber
→ SockAddr
res = Response {
resVersion = HttpVersion 1 1
, resStatus = arInitialStatus ar
- , resHeaders = singleton "Content-Type" defaultPageContentType
+ , resHeaders = (∅)
}
reqBodyWanted ← newTVarIO 0
receivedBody ← newTVarIO S.empty
receivedBodyLen ← newTVarIO 0
- response ← newTVarIO res
- willChunkBody ← newTVarIO False
- willDiscardBody ← newTVarIO (arWillDiscardBody ar)
- willClose ← newTVarIO (arWillClose ar)
- bodyToSend ← newEmptyTMVarIO
- sentNoBodySoFar ← newTVarIO True
+ response ← newTVarIO res
+ willChunkBody ← newTVarIO False
+ willDiscardBody ← newTVarIO (arWillDiscardBody ar)
+ willClose ← newTVarIO (arWillClose ar)
+ bodyToSend ← newEmptyTMVarIO
+ responseHasCType ← newTVarIO False
- state ← newTVarIO ExaminingRequest
+ state ← newTVarIO ExaminingRequest
return Interaction {
itrConfig = conf
, itrWillChunkBody = willChunkBody
, itrWillDiscardBody = willDiscardBody
, itrWillClose = willClose
+ , itrResponseHasCType = responseHasCType
, itrBodyToSend = bodyToSend
- , itrSentNoBodySoFar = sentNoBodySoFar
, itrState = state
}