on master help sign in
Merge pull request #726 from yesodweb/deprecateRequestBody

Deprecate requestBody

commit1670868bd440962e38c4b26c04edfca8d78b24ba authorMichael Snoyman <michael@snoyman.com> dateTue 22 Jan 2019, 09:36 (8 years ago) parent96c70a820bcbef
4 files changed+18−4
wai/ChangeLog.md+4 wai/Network/Wai.hs+4−2 wai/Network/Wai/Internal.hs+9−1 wai/wai.cabal+1−1
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+
15## 3.2.1.2
26
37* Remove dependency on blaze-builder [#683](https://github.com/yesodweb/wai/pull/683)
wai/Network/Wai.hs+4−2
@@ -33,6 +33,8 @@ include:
3333[wai-test] <http://hackage.haskell.org/package/wai-test>
3434
3535-}
36+-- Ignore deprecations, because this module needs to use the deprecated requestBody to construct a response.
37+{-# OPTIONS_GHC -fno-warn-deprecations #-}
3638module Network.Wai
3739 (
3840 -- * Types
@@ -325,7 +327,7 @@ strictRequestBody req =
325327 loop id
326328 where
327329 loop front = do
328− bs <- requestBody req
330+ bs <- getRequestBodyChunk req
329331 if B.null bs
330332 then return $ front LI.Empty
331333 else loop (front . LI.Chunk bs)
@@ -339,7 +341,7 @@ lazyRequestBody req =
339341 loop
340342 where
341343 loop = unsafeInterleaveIO $ do
342− bs <- requestBody req
344+ bs <- getRequestBodyChunk req
343345 if B.null bs
344346 then return LI.Empty
345347 else do
wai/Network/Wai/Internal.hs+9−1
@@ -17,6 +17,7 @@ import Data.List (intercalate)
1717
1818-- | Information on the request sent by the client. This abstracts away the
1919-- 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." #-}
2021data Request = Request {
2122 -- | Request method such as GET.
2223 requestMethod :: H.Method
@@ -62,7 +63,7 @@ data Request = Request {
6263 -- | Parsed query string information.
6364 , queryString :: H.Query
6465 -- | 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'.
6667 , requestBody :: IO B.ByteString
6768 -- | A location for arbitrary data to be shared by applications and middleware.
6869 , vault :: Vault
@@ -90,6 +91,13 @@ data Request = Request {
9091 }
9192 deriving (Typeable)
9293
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+
93101instance Show Request where
94102 show Request{..} = "Request {" ++ intercalate ", " [a ++ " = " ++ b | (a,b) <- fields] ++ "}"
95103 where
wai/wai.cabal+1−1
@@ -1,5 +1,5 @@
11Name: wai
2−Version: 3.2.1.2
2+Version: 3.2.2
33Synopsis: Web Application Interface.
44Description: Provides a common protocol for communication between web applications and web servers.
55 .