module Network.Wai.Handler.Warp.Types where
import Control.Exception
import Data.ByteString (ByteString)
import Data.Typeable (Typeable)
import Data.Version (showVersion)
import Network.HTTP.Types.Header
import qualified Paths_warp
import qualified Network.Wai.Handler.Warp.Timeout as T
#if SENDFILEFD
import qualified Network.Wai.Handler.Warp.FdCache as F
#endif
warpVersion :: String
warpVersion = showVersion Paths_warp.version
type Port = Int
hTransferEncoding :: HeaderName
hTransferEncoding = "Transfer-Encoding"
hHost :: HeaderName
hHost = "Host"
hServer :: HeaderName
hServer = "Server"
data InvalidRequest =
NotEnoughLines [String]
| BadFirstLine String
| NonHttp
| IncompleteHeaders
| ConnectionClosedByPeer
| OverLargeHeader
deriving (Eq, Show, Typeable)
instance Exception InvalidRequest
data Connection = Connection
{ connSendMany :: [ByteString] -> IO ()
, connSendAll :: ByteString -> IO ()
, connSendFile :: FilePath -> Integer -> Integer -> IO () -> [ByteString] -> Cleaner -> IO ()
, connClose :: IO ()
, connRecv :: IO ByteString
}
dummyCleaner :: Cleaner
#if SENDFILEFD
dummyCleaner = Cleaner T.dummyHandle Nothing
data Cleaner = Cleaner {
threadHandle :: T.Handle
, fdCacher :: Maybe F.MutableFdCache
}
#else
dummyCleaner = Cleaner T.dummyHandle
newtype Cleaner = Cleaner { threadHandle :: T.Handle }
#endif