{-# OPTIONS_HADDOCK not-home #-}
{-# LANGUAGE CPP #-}
{-# LANGUAGE RecordWildCards #-}
module Network.Wai.Internal where
import Data.ByteString.Builder (Builder)
import qualified Data.ByteString as B hiding (pack)
import Data.Text (Text)
import Data.Typeable (Typeable)
import Data.Vault.Lazy (Vault)
import Data.Word (Word64)
import qualified Network.HTTP.Types as H
import Network.Socket (SockAddr)
import Data.List (intercalate)
{-# DEPRECATED requestBody "requestBody's name is misleading because it only gets a partial chunk of the body. Use getRequestBodyChunk instead." #-}
data Request = Request {
Request -> Method
requestMethod :: H.Method
, Request -> HttpVersion
httpVersion :: H.HttpVersion
, Request -> Method
rawPathInfo :: B.ByteString
, Request -> Method
rawQueryString :: B.ByteString
, :: H.RequestHeaders
, Request -> Bool
isSecure :: Bool
, Request -> SockAddr
remoteHost :: SockAddr
, Request -> [Text]
pathInfo :: [Text]
, Request -> Query
queryString :: H.Query
, Request -> IO Method
requestBody :: IO B.ByteString
, Request -> Vault
vault :: Vault
, Request -> RequestBodyLength
requestBodyLength :: RequestBodyLength
, :: Maybe B.ByteString
, :: Maybe B.ByteString
, :: Maybe B.ByteString
, :: Maybe B.ByteString
}
deriving (Typeable)
getRequestBodyChunk :: Request -> IO B.ByteString
getRequestBodyChunk :: Request -> IO Method
getRequestBodyChunk = Request -> IO Method
requestBody
instance Show Request where
show :: Request -> String
show Request{Bool
Query
RequestHeaders
[Text]
Maybe Method
IO Method
Method
HttpVersion
SockAddr
Vault
RequestBodyLength
requestMethod :: Request -> Method
httpVersion :: Request -> HttpVersion
rawPathInfo :: Request -> Method
rawQueryString :: Request -> Method
requestHeaders :: Request -> RequestHeaders
isSecure :: Request -> Bool
remoteHost :: Request -> SockAddr
pathInfo :: Request -> [Text]
queryString :: Request -> Query
requestBody :: Request -> IO Method
vault :: Request -> Vault
requestBodyLength :: Request -> RequestBodyLength
requestHeaderHost :: Request -> Maybe Method
requestHeaderRange :: Request -> Maybe Method
requestHeaderReferer :: Request -> Maybe Method
requestHeaderUserAgent :: Request -> Maybe Method
requestMethod :: Method
httpVersion :: HttpVersion
rawPathInfo :: Method
rawQueryString :: Method
requestHeaders :: RequestHeaders
isSecure :: Bool
remoteHost :: SockAddr
pathInfo :: [Text]
queryString :: Query
requestBody :: IO Method
vault :: Vault
requestBodyLength :: RequestBodyLength
requestHeaderHost :: Maybe Method
requestHeaderRange :: Maybe Method
requestHeaderReferer :: Maybe Method
requestHeaderUserAgent :: Maybe Method
..} = String
"Request {" String -> ShowS
forall a. [a] -> [a] -> [a]
++ String -> [String] -> String
forall a. [a] -> [[a]] -> [a]
intercalate String
", " [String
a String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
" = " String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
b | (String
a,String
b) <- [(String, String)]
fields] String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
"}"
where
fields :: [(String, String)]
fields =
[(String
"requestMethod",Method -> String
forall a. Show a => a -> String
show Method
requestMethod)
,(String
"httpVersion",HttpVersion -> String
forall a. Show a => a -> String
show HttpVersion
httpVersion)
,(String
"rawPathInfo",Method -> String
forall a. Show a => a -> String
show Method
rawPathInfo)
,(String
"rawQueryString",Method -> String
forall a. Show a => a -> String
show Method
rawQueryString)
,(String
"requestHeaders",RequestHeaders -> String
forall a. Show a => a -> String
show RequestHeaders
requestHeaders)
,(String
"isSecure",Bool -> String
forall a. Show a => a -> String
show Bool
isSecure)
,(String
"remoteHost",SockAddr -> String
forall a. Show a => a -> String
show SockAddr
remoteHost)
,(String
"pathInfo",[Text] -> String
forall a. Show a => a -> String
show [Text]
pathInfo)
,(String
"queryString",Query -> String
forall a. Show a => a -> String
show Query
queryString)
,(String
"requestBody",String
"<IO ByteString>")
,(String
"vault",String
"<Vault>")
,(String
"requestBodyLength",RequestBodyLength -> String
forall a. Show a => a -> String
show RequestBodyLength
requestBodyLength)
,(String
"requestHeaderHost",Maybe Method -> String
forall a. Show a => a -> String
show Maybe Method
requestHeaderHost)
,(String
"requestHeaderRange",Maybe Method -> String
forall a. Show a => a -> String
show Maybe Method
requestHeaderRange)
]
data Response
= ResponseFile H.Status H.ResponseHeaders FilePath (Maybe FilePart)
| ResponseBuilder H.Status H.ResponseHeaders Builder
| ResponseStream H.Status H.ResponseHeaders StreamingBody
| ResponseRaw (IO B.ByteString -> (B.ByteString -> IO ()) -> IO ()) Response
deriving Typeable
type StreamingBody = (Builder -> IO ()) -> IO () -> IO ()
data RequestBodyLength = ChunkedBody | KnownLength Word64 deriving Int -> RequestBodyLength -> ShowS
[RequestBodyLength] -> ShowS
RequestBodyLength -> String
(Int -> RequestBodyLength -> ShowS)
-> (RequestBodyLength -> String)
-> ([RequestBodyLength] -> ShowS)
-> Show RequestBodyLength
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> RequestBodyLength -> ShowS
showsPrec :: Int -> RequestBodyLength -> ShowS
$cshow :: RequestBodyLength -> String
show :: RequestBodyLength -> String
$cshowList :: [RequestBodyLength] -> ShowS
showList :: [RequestBodyLength] -> ShowS
Show
data FilePart = FilePart
{ FilePart -> Integer
filePartOffset :: Integer
, FilePart -> Integer
filePartByteCount :: Integer
, FilePart -> Integer
filePartFileSize :: Integer
} deriving Int -> FilePart -> ShowS
[FilePart] -> ShowS
FilePart -> String
(Int -> FilePart -> ShowS)
-> (FilePart -> String) -> ([FilePart] -> ShowS) -> Show FilePart
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> FilePart -> ShowS
showsPrec :: Int -> FilePart -> ShowS
$cshow :: FilePart -> String
show :: FilePart -> String
$cshowList :: [FilePart] -> ShowS
showList :: [FilePart] -> ShowS
Show
data ResponseReceived = ResponseReceived
deriving Typeable