Skip to content

Commit

Permalink
requestBodyLength yesodweb/yesod#468
Browse files Browse the repository at this point in the history
  • Loading branch information
snoyberg committed Feb 18, 2013
1 parent e13c50a commit 613242a
Show file tree
Hide file tree
Showing 17 changed files with 51 additions and 28 deletions.
4 changes: 2 additions & 2 deletions wai-app-static/wai-app-static.cabal
@@ -1,5 +1,5 @@
name: wai-app-static
version: 1.3.1.1
version: 1.3.1.2
license: MIT
license-file: LICENSE
author: Michael Snoyman <michael@snoyman.com>
Expand All @@ -24,7 +24,7 @@ Flag print

library
build-depends: base >= 4 && < 5
, wai >= 1.3 && < 1.4
, wai >= 1.3 && < 1.5
, bytestring >= 0.9.1.4
, http-types >= 0.7
, transformers >= 0.2.2
Expand Down
4 changes: 2 additions & 2 deletions wai-eventsource/wai-eventsource.cabal
@@ -1,5 +1,5 @@
Name: wai-eventsource
Version: 1.3.0.3
Version: 1.3.0.4
Synopsis: WAI support for server-sent events
Description: WAI support for server-sent events
License: MIT
Expand All @@ -19,7 +19,7 @@ Library
, blaze-builder >= 0.3 && < 0.4
, conduit >= 0.5 && < 1.1
, http-types >= 0.7
, wai >= 1.3 && < 1.4
, wai >= 1.3 && < 1.5
, warp >= 1.3 && < 1.4
, transformers

Expand Down
4 changes: 4 additions & 0 deletions wai-extra/Network/Wai/Handler/CGI.hs
@@ -1,5 +1,6 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE CPP #-}
-- | Backend for Common Gateway Interface. Almost all users should use the
-- 'run' function.
module Network.Wai.Handler.CGI
Expand Down Expand Up @@ -109,6 +110,9 @@ runGeneric vars inputH outputH xsendfile app = do
, httpVersion = H.http11 -- FIXME
, requestBody = inputH contentLength
, vault = mempty
#if MIN_VERSION_wai(1, 4, 0)
, requestBodyLength = KnownLength $ fromIntegral contentLength
#endif
}
-- FIXME worry about exception?
res <- app env
Expand Down
4 changes: 2 additions & 2 deletions wai-extra/wai-extra.cabal
@@ -1,5 +1,5 @@
Name: wai-extra
Version: 1.3.2.3
Version: 1.3.2.4
Synopsis: Provides some basic WAI handlers and middleware.
Description: The goal here is to provide common features without many dependencies.
License: MIT
Expand All @@ -22,7 +22,7 @@ extra-source-files:
Library
Build-Depends: base >= 4 && < 5
, bytestring >= 0.9.1.4
, wai >= 1.3 && < 1.4
, wai >= 1.3 && < 1.5
, old-locale >= 1.0.0.2 && < 1.1
, time >= 1.1.4
, network >= 2.2.1.5
Expand Down
4 changes: 2 additions & 2 deletions wai-frontend-monadcgi/wai-frontend-monadcgi.cabal
@@ -1,5 +1,5 @@
name: wai-frontend-monadcgi
version: 1.3.0.1
version: 1.3.0.2
license: MIT
license-file: LICENSE
author: Michael Snoyman <michael@snoyman.com>
Expand All @@ -20,7 +20,7 @@ library
, http-types
, transformers
, case-insensitive
, wai >= 1.3 && < 1.4
, wai >= 1.3 && < 1.5
exposed-modules: Network.Wai.Frontend.MonadCGI
ghc-options: -Wall

Expand Down
4 changes: 2 additions & 2 deletions wai-handler-devel/wai-handler-devel.cabal
@@ -1,5 +1,5 @@
Name: wai-handler-devel
Version: 1.3.0.4
Version: 1.3.0.5
Synopsis: WAI server that automatically reloads code after modification.
Description: This handler automatically reloads your source code upon any changes. It works by using the hint package, essentially embedding GHC inside the handler. The handler (both the executable and library) takes three arguments: the port to listen on, the module name containing the application function, and the name of the function.
.
Expand All @@ -22,7 +22,7 @@ Source-repository head

Library
Build-Depends: base >= 4 && < 5
, wai >= 1.3 && < 1.4
, wai >= 1.3 && < 1.5
, wai-extra >= 1.3 && < 1.4
, http-types >= 0.7
, warp >= 1.3 && < 1.4
Expand Down
4 changes: 2 additions & 2 deletions wai-handler-fastcgi/wai-handler-fastcgi.cabal
@@ -1,5 +1,5 @@
name: wai-handler-fastcgi
version: 1.3.0.1
version: 1.3.0.2
license: MIT
license-file: LICENSE
author: Michael Snoyman <michael@snoyman.com>
Expand All @@ -15,7 +15,7 @@ description: Calls out to the libfcgi C library.

library
build-depends: base >= 4 && < 5
, wai >= 1.3 && < 1.4
, wai >= 1.3 && < 1.5
, wai-extra >= 1.3 && < 1.4
, bytestring >= 0.9.1.4
exposed-modules: Network.Wai.Handler.FastCGI
Expand Down
4 changes: 2 additions & 2 deletions wai-handler-launch/wai-handler-launch.cabal
@@ -1,5 +1,5 @@
Name: wai-handler-launch
Version: 1.3.1.3
Version: 1.3.1.4
Synopsis: Launch a web app in the default browser.
Description: This handles cross-platform launching and inserts Javascript code to ping the server. When the server no longer receives pings, it shuts down.
License: MIT
Expand All @@ -13,7 +13,7 @@ Cabal-version: >=1.6
Library
Exposed-modules: Network.Wai.Handler.Launch
build-depends: base >= 4 && < 5
, wai >= 1.3 && < 1.4
, wai >= 1.3 && < 1.5
, warp >= 1.3 && < 1.4
, http-types >= 0.7
, transformers >= 0.2.2 && < 0.4
Expand Down
4 changes: 2 additions & 2 deletions wai-handler-scgi/wai-handler-scgi.cabal
@@ -1,5 +1,5 @@
name: wai-handler-scgi
version: 1.3.0.1
version: 1.3.0.2
license: MIT
license-file: LICENSE
author: Michael Snoyman <michael@snoyman.com>
Expand All @@ -14,7 +14,7 @@ description: Wai handler to SCGI

library
build-depends: base >= 4 && < 5
, wai >= 1.3 && < 1.4
, wai >= 1.3 && < 1.5
, wai-extra >= 1.3 && < 1.4
, bytestring >= 0.9.1.4
exposed-modules: Network.Wai.Handler.SCGI
Expand Down
6 changes: 3 additions & 3 deletions wai-handler-webkit/wai-handler-webkit.cabal
@@ -1,5 +1,5 @@
name: wai-handler-webkit
version: 1.3.0
version: 1.3.0.1
license: MIT
license-file: LICENSE
author: Michael Snoyman <michael@snoyman.com>
Expand All @@ -16,8 +16,8 @@ homepage: http://www.yesodweb.com/book/web-application-interface

library
build-depends: base >= 4 && < 5
, wai >= 1.3 && < 1.4
, warp >= 1.3 && < 1.4
, wai >= 1.3 && < 1.5
, warp >= 1.3 && < 1.5
ghc-options: -Wall
exposed-modules: Network.Wai.Handler.Webkit
c-sources: webkit.cpp
Expand Down
4 changes: 2 additions & 2 deletions wai-test/wai-test.cabal
@@ -1,5 +1,5 @@
name: wai-test
version: 1.3.0.2
version: 1.3.0.3
license: MIT
license-file: LICENSE
author: Michael Snoyman <michael@snoyman.com>
Expand All @@ -14,7 +14,7 @@ description: Unit test framework (built on HUnit) for WAI applications.

library
build-depends: base >= 4 && < 5
, wai >= 1.3 && < 1.4
, wai >= 1.3 && < 1.5
, bytestring >= 0.9.1.4
, text >= 0.7 && < 0.12
, blaze-builder >= 0.2.1.4 && < 0.4
Expand Down
4 changes: 2 additions & 2 deletions wai-websockets/wai-websockets.cabal
@@ -1,5 +1,5 @@
Name: wai-websockets
Version: 1.3.1.1
Version: 1.3.1.2
Synopsis: Provide a bridge betweeen WAI and the websockets package.
License: MIT
License-file: LICENSE
Expand All @@ -20,7 +20,7 @@ Library
Build-Depends: base >= 3 && < 5
, bytestring >= 0.9.1.4
, conduit >= 0.5 && < 1.1
, wai >= 1.3 && < 1.4
, wai >= 1.3 && < 1.5
, enumerator >= 0.4.8 && < 0.5
, network-enumerator >= 0.1.2 && < 0.2
, blaze-builder >= 0.2.1.4 && < 0.4
Expand Down
12 changes: 12 additions & 0 deletions wai/Network/Wai.hs
Expand Up @@ -43,6 +43,7 @@ module Network.Wai
, Application
, Middleware
, FilePart (..)
, RequestBodyLength (..)
-- * Response body smart constructors
, responseLBS
, responseStatus
Expand All @@ -61,6 +62,7 @@ import Data.Text (Text)
import Data.ByteString.Lazy.Char8 () -- makes it easier to use responseLBS
import Blaze.ByteString.Builder (fromByteString)
import Data.Vault (Vault)
import Data.Word (Word64)

-- | Information on the request sent by the client. This abstracts away the
-- details of the underlying implementation.
Expand Down Expand Up @@ -98,6 +100,10 @@ data Request = Request
, requestBody :: C.Source (C.ResourceT IO) B.ByteString
-- | A location for arbitrary data to be shared by applications and middleware.
, vault :: Vault
-- | The size of the request body. In the case of a chunked request body, this may be unknown.
--
-- Since 1.4.0
, requestBodyLength :: RequestBodyLength
}
deriving (Typeable)

Expand Down Expand Up @@ -175,3 +181,9 @@ type Application = Request -> C.ResourceT IO Response
-- Here, instead of taking a standard 'Application' as its first argument, the
-- middleware takes a function which consumes the session information as well.
type Middleware = Application -> Application

-- | The size of the request body. In the case of chunked bodies, the size will
-- not be known.
--
-- Since 1.4.0
data RequestBodyLength = ChunkedBody | KnownLength Word64
2 changes: 1 addition & 1 deletion wai/wai.cabal
@@ -1,5 +1,5 @@
Name: wai
Version: 1.3.0.3
Version: 1.4.0
Synopsis: Web Application Interface.
Description: Provides a common protocol for communication between web applications and web servers.
License: MIT
Expand Down
2 changes: 1 addition & 1 deletion warp-tls/warp-tls.cabal
Expand Up @@ -15,7 +15,7 @@ Description: SSL support for Warp via the TLS package
Library
Build-Depends: base >= 4 && < 5
, bytestring >= 0.9
, wai >= 1.3 && < 1.4
, wai >= 1.3 && < 1.5
, warp >= 1.3.5 && < 1.4
, transformers >= 0.2
, conduit >= 0.5 && < 1.1
Expand Down
7 changes: 7 additions & 0 deletions warp/Network/Wai/Handler/Warp/Request.hs
@@ -1,5 +1,6 @@
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE CPP #-}

module Network.Wai.Handler.Warp.Request where

Expand Down Expand Up @@ -98,6 +99,12 @@ parseRequest' conn port (firstLine:otherLines) remoteHost' src = do
, remoteHost = remoteHost'
, requestBody = rbody
, vault = mempty
#if MIN_VERSION_wai(1, 4, 0)
, requestBodyLength =
if chunked
then ChunkedBody
else KnownLength $ fromIntegral len0
#endif
}, getSource)

{-# INLINE takeUntil #-}
Expand Down
6 changes: 3 additions & 3 deletions warp/warp.cabal
@@ -1,5 +1,5 @@
Name: warp
Version: 1.3.7.3
Version: 1.3.7.4
Synopsis: A fast, light-weight web server for WAI applications.
License: MIT
License-file: LICENSE
Expand Down Expand Up @@ -35,7 +35,7 @@ Library
, transformers >= 0.2.2 && < 0.4
, unix-compat >= 0.2
, void
, wai >= 1.3 && < 1.4
, wai >= 1.3 && < 1.5
if flag(network-bytestring)
Build-Depends: network >= 2.2.1.5 && < 2.2.3
, network-bytestring >= 0.1.3 && < 0.1.4
Expand Down Expand Up @@ -83,7 +83,7 @@ Test-Suite spec
, transformers >= 0.2.2 && < 0.4
, unix-compat >= 0.2
, void
, wai >= 1.3 && < 1.4
, wai
, network
, HUnit
, QuickCheck
Expand Down

0 comments on commit 613242a

Please sign in to comment.