Skip to content

Commit

Permalink
Export more request types
Browse files Browse the repository at this point in the history
  • Loading branch information
jaspervdj committed Sep 13, 2012
1 parent 7a0ca9c commit bf248d4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
8 changes: 6 additions & 2 deletions src/Network/WebSockets.hs
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,15 @@ module Network.WebSockets
, I.runServer
, I.runWithSocket

-- * Types
-- * HTTP Types
, I.Headers
, I.RequestHttpPart (..)
, I.Request (..)
, I.RequestHttpPart (..)
, I.RequestBody (..)
, I.ResponseHttpPart (..)
, I.ResponseBody (..)

-- * WebSockets types
, I.Message (..)
, I.ControlMessage (..)
, I.DataMessage (..)
Expand Down
17 changes: 9 additions & 8 deletions src/Network/WebSockets/Handshake/Http.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
{-# LANGUAGE DeriveDataTypeable, OverloadedStrings #-}
module Network.WebSockets.Handshake.Http
( Headers
, Request (..)
, RequestHttpPart (..)
, RequestBody (..)
, Request (..)
, ResponseHttpPart (..)
, ResponseBody (..)
, HandshakeError (..)
Expand Down Expand Up @@ -45,6 +45,13 @@ import qualified Data.Enumerator as E
-- | Request headers
type Headers = [(CI.CI B.ByteString, B.ByteString)]

-- | Full request type, including the response to it
data Request = Request
{ requestPath :: !B.ByteString
, requestHeaders :: Headers
, requestResponse :: ResponseBody
} deriving (Show)

-- | (Internally used) HTTP headers and requested path.
data RequestHttpPart = RequestHttpPart
{ requestHttpPath :: !B.ByteString
Expand All @@ -56,20 +63,14 @@ data RequestHttpPart = RequestHttpPart
data RequestBody = RequestBody RequestHttpPart B.ByteString
deriving (Show)

-- | Full request type
data Request = Request
{ requestPath :: !B.ByteString
, requestHeaders :: Headers
, requestResponse :: ResponseBody
} deriving (Show)

-- | Response to a 'Request'
data ResponseHttpPart = ResponseHttpPart
{ responseHttpCode :: !Int
, responseHttpMessage :: !B.ByteString
, responseHttpHeaders :: Headers
} deriving (Show)

-- | A response including a body
data ResponseBody = ResponseBody ResponseHttpPart B.ByteString
deriving (Show)

Expand Down

0 comments on commit bf248d4

Please sign in to comment.