@@ -43,6 +43,7 @@ module Network.Wai
4343 , Application
4444 , Middleware
4545 , FilePart (..)
46+ , RequestBodyLength (..)
4647 -- * Response body smart constructors
4748 , responseLBS
4849 , responseStatus
@@ -61,6 +62,7 @@ import Data.Text (Text)
6162import Data.ByteString.Lazy.Char8 () -- makes it easier to use responseLBS
6263import Blaze.ByteString.Builder (fromByteString)
6364import Data.Vault (Vault)
65+import Data.Word (Word64)
6466
6567-- | Information on the request sent by the client. This abstracts away the
6668-- details of the underlying implementation.
@@ -98,6 +100,10 @@ data Request = Request
98100 , requestBody :: C.Source (C.ResourceT IO) B.ByteString
99101 -- | A location for arbitrary data to be shared by applications and middleware.
100102 , vault :: Vault
103+ -- | The size of the request body. In the case of a chunked request body, this may be unknown.
104+ --
105+ -- Since 1.4.0
106+ , requestBodyLength :: RequestBodyLength
101107 }
102108 deriving (Typeable)
103109
@@ -175,3 +181,9 @@ type Application = Request -> C.ResourceT IO Response
175181-- Here, instead of taking a standard 'Application' as its first argument, the
176182-- middleware takes a function which consumes the session information as well.
177183type Middleware = Application -> Application
184+
185+-- | The size of the request body. In the case of chunked bodies, the size will
186+-- not be known.
187+--
188+-- Since 1.4.0
189+data RequestBodyLength = ChunkedBody | KnownLength Word64