X-Git-Url: http://git.cielonegro.org/gitweb.cgi?p=Lucu.git;a=blobdiff_plain;f=Network%2FHTTP%2FLucu%2FInteraction.hs;h=4ac7c093607729fe8784acc3f8e914c96fed1b66;hp=3ecc9126f4292a63a239db5a0efb246f76909402;hb=72a3e24;hpb=895341e8b790e969be678c5cfb85c878e321c8fc diff --git a/Network/HTTP/Lucu/Interaction.hs b/Network/HTTP/Lucu/Interaction.hs index 3ecc912..4ac7c09 100644 --- a/Network/HTTP/Lucu/Interaction.hs +++ b/Network/HTTP/Lucu/Interaction.hs @@ -9,21 +9,19 @@ module Network.HTTP.Lucu.Interaction , 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 @@ -51,8 +49,8 @@ data Interaction = Interaction { , itrWillChunkBody ∷ !(TVar Bool) , itrWillDiscardBody ∷ !(TVar Bool) , itrWillClose ∷ !(TVar Bool) + , itrResponseHasCType ∷ !(TVar Bool) , itrBodyToSend ∷ !(TMVar Builder) - , itrSentNoBodySoFar ∷ !(TVar Bool) , itrState ∷ !(TVar InteractionState) } @@ -71,9 +69,6 @@ type InteractionQueue = TVar (Seq Interaction) newInteractionQueue ∷ IO InteractionQueue newInteractionQueue = newTVarIO S.empty -defaultPageContentType ∷ Ascii -defaultPageContentType = "application/xhtml+xml" - newInteraction ∷ Config → PortNumber → SockAddr @@ -85,7 +80,7 @@ newInteraction conf@(Config {..}) port addr cert request res = Response { resVersion = HttpVersion 1 1 , resStatus = arInitialStatus ar - , resHeaders = singleton "Content-Type" defaultPageContentType + , resHeaders = (∅) } reqBodyWanted ← newTVarIO 0 @@ -94,14 +89,14 @@ newInteraction conf@(Config {..}) port addr cert request 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 @@ -124,8 +119,8 @@ newInteraction conf@(Config {..}) port addr cert request , itrWillChunkBody = willChunkBody , itrWillDiscardBody = willDiscardBody , itrWillClose = willClose + , itrResponseHasCType = responseHasCType , itrBodyToSend = bodyToSend - , itrSentNoBodySoFar = sentNoBodySoFar , itrState = state }