packages feed

mongrel2-handler 0.3.0 → 0.3.1

raw patch · 3 files changed

+33/−5 lines, 3 filesdep ~attoparsecdep ~blaze-textualPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: attoparsec, blaze-textual

API changes (from Hackage documentation)

+ Mongrel2: buildResponse :: Status -> ResponseHeaders -> ByteString -> Builder

Files

mongrel2-handler.cabal view
@@ -1,5 +1,5 @@ Name:                mongrel2-handler-Version:             0.3.0+Version:             0.3.1 Synopsis:            Mongrel2 Handler Library Description:         Mongrel2 Handler Library. @@ -17,9 +17,9 @@  Library   Build-Depends: base             >= 4.0 && <5-               , attoparsec       >= 0.8.5.0 && < 0.9+               , attoparsec       >= 0.8.5.0 && < 0.10                , blaze-builder    >= 0.3 && < 0.4-               , blaze-textual    >= 0.1 && < 0.2+               , blaze-textual    >= 0.1 && < 0.3                , bytestring       >= 0.9.0.1                , case-insensitive >= 0.2 && < 0.3                , containers       >= 0.3 && < 0.5
src/Mongrel2.hs view
@@ -6,17 +6,18 @@        , receiveRequest        , sendReply        -- Re-exported+       , buildResponse+       , ClientID        , Connection(..)        , Request(..)        , UUID-       , ClientID        ) where  import Blaze.ByteString.Builder (Builder) import Data.Attoparsec import Mongrel2.Types (Connection(..), Request(..)) import Mongrel2.Parser (messageParser, UUID, ClientID)-import Mongrel2.Response (mkResponse)+import Mongrel2.Response (buildResponse, mkResponse) import qualified System.ZMQ as ZMQ  data Handler = Handler { handlerPullFrom :: String
src/Mongrel2/Response.hs view
@@ -1,5 +1,6 @@ module Mongrel2.Response        ( Response+       , buildResponse        , mkResponse        ) where @@ -10,7 +11,9 @@ import Data.List (intersperse) import Data.Monoid import Mongrel2.Types (ClientID, UUID)+import Network.HTTP.Types (Status(..), ResponseHeaders) import qualified Data.ByteString as S+import qualified Data.CaseInsensitive as CI  -- | Raw response type. type Response = ByteString@@ -48,3 +51,27 @@                          , buildNetstring $ buildClientIDList clientIDs                          , fromByteString ", "                          , bodyBuilder ]++-- | Build a HTTP response.+buildResponse :: Status -> ResponseHeaders -> ByteString -> Builder+buildResponse status responseHeaders body =+  mconcat [ fromByteString "HTTP/1.1 "+          , integral $ statusCode status+          , fromByteString " "+          , fromByteString $ statusMessage status+          , crlf+          , mconcat $ map buildResponseHeader responseHeaders+          , crlf+          , fromByteString body+          ]+  where++    buildResponseHeader (name,value) =+      mconcat [ fromByteString $ CI.original name+              , fromByteString ": "+              , fromByteString value+              , crlf+              ]++    crlf = fromByteString "\r\n"+