on master help sign in
Merge pull request #726 from yesodweb/deprecateRequestBody
1670868Michael Snoyman
wai/ChangeLog.md+4
@@ -1,3 +1,7 @@
1+## 3.2.2
2+
3+* Deprecate `requestBody` in favor of the more clearly named `getRequestBodyChunk`. [#726](https://github.com/yesodweb/wai/pull/726)
4+
1## 3.2.1.2
5## 3.2.1.2
2
6
3* Remove dependency on blaze-builder [#683](https://github.com/yesodweb/wai/pull/683)
7* Remove dependency on blaze-builder [#683](https://github.com/yesodweb/wai/pull/683)
wai/Network/Wai.hs+4−2
@@ -33,6 +33,8 @@ include:
33[wai-test] <http://hackage.haskell.org/package/wai-test>
33[wai-test] <http://hackage.haskell.org/package/wai-test>
34
34
35-}
35-}
36+-- Ignore deprecations, because this module needs to use the deprecated requestBody to construct a response.
37+{-# OPTIONS_GHC -fno-warn-deprecations #-}
36module Network.Wai
38module Network.Wai
37 (
39 (
38 -- * Types
40 -- * Types
@@ -325,7 +327,7 @@ strictRequestBody req =
325 loop id
327 loop id
326 where
328 where
327 loop front = do
329 loop front = do
328− bs <- requestBody req
330+ bs <- getRequestBodyChunk req
329 if B.null bs
331 if B.null bs
330 then return $ front LI.Empty
332 then return $ front LI.Empty
331 else loop (front . LI.Chunk bs)
333 else loop (front . LI.Chunk bs)
@@ -339,7 +341,7 @@ lazyRequestBody req =
339 loop
341 loop
340 where
342 where
341 loop = unsafeInterleaveIO $ do
343 loop = unsafeInterleaveIO $ do
342− bs <- requestBody req
344+ bs <- getRequestBodyChunk req
343 if B.null bs
345 if B.null bs
344 then return LI.Empty
346 then return LI.Empty
345 else do
347 else do
wai/Network/Wai/Internal.hs+9−1
@@ -17,6 +17,7 @@ import Data.List (intercalate)
17
17
18-- | Information on the request sent by the client. This abstracts away the
18-- | Information on the request sent by the client. This abstracts away the
19-- details of the underlying implementation.
19-- details of the underlying implementation.
20+{-# DEPRECATED requestBody "requestBody's name is misleading because it only gets a partial chunk of the body. Use getRequestBodyChunk instead." #-}
20data Request = Request {
21data Request = Request {
21 -- | Request method such as GET.
22 -- | Request method such as GET.
22 requestMethod :: H.Method
23 requestMethod :: H.Method
@@ -62,7 +63,7 @@ data Request = Request {
62 -- | Parsed query string information.
63 -- | Parsed query string information.
63 , queryString :: H.Query
64 , queryString :: H.Query
64 -- | Get the next chunk of the body. Returns 'B.empty' when the
65 -- | Get the next chunk of the body. Returns 'B.empty' when the
65− -- body is fully consumed.
66+ -- body is fully consumed. Since 3.2.2, this is deprecated in favor of 'getRequestBodyChunk'.
66 , requestBody :: IO B.ByteString
67 , requestBody :: IO B.ByteString
67 -- | A location for arbitrary data to be shared by applications and middleware.
68 -- | A location for arbitrary data to be shared by applications and middleware.
68 , vault :: Vault
69 , vault :: Vault
@@ -90,6 +91,13 @@ data Request = Request {
90 }
91 }
91 deriving (Typeable)
92 deriving (Typeable)
92
93
94+-- | Get the next chunk of the body. Returns 'B.empty' when the
95+-- body is fully consumed.
96+--
97+-- @since 3.2.2
98+getRequestBodyChunk :: Request -> IO B.ByteString
99+getRequestBodyChunk = requestBody
100+
93instance Show Request where
101instance Show Request where
94 show Request{..} = "Request {" ++ intercalate ", " [a ++ " = " ++ b | (a,b) <- fields] ++ "}"
102 show Request{..} = "Request {" ++ intercalate ", " [a ++ " = " ++ b | (a,b) <- fields] ++ "}"
95 where
103 where
wai/wai.cabal+1−1
@@ -1,5 +1,5 @@
1Name: wai
1Name: wai
2−Version: 3.2.1.2
2+Version: 3.2.2
3Synopsis: Web Application Interface.
3Synopsis: Web Application Interface.
4Description: Provides a common protocol for communication between web applications and web servers.
4Description: Provides a common protocol for communication between web applications and web servers.
5 .
5 .