@@ -59,6 +59,7 @@ module Network.Wai
5959 , requestBodyLength
6060 , requestHeaderHost
6161 , requestHeaderRange
62+ , strictRequestBody
6263 , lazyRequestBody
6364 -- * Response
6465 , Response
@@ -278,6 +279,20 @@ defaultRequest = Request
278279 , requestHeaderRange = Nothing
279280 }
280281
282+-- | Get the request body as a lazy ByteString. However, do /not/ use any lazy
283+-- I\/O, instead reading the entire body into memory strictly.
284+--
285+-- Since 3.0.1
286+strictRequestBody :: Request -> IO L.ByteString
287+strictRequestBody req =
288+ loop id
289+ where
290+ loop front = do
291+ bs <- requestBody req
292+ if B.null bs
293+ then return $ front LI.Empty
294+ else loop (front . LI.Chunk bs)
295+
281296-- | Get the request body as a lazy ByteString. This uses lazy I\/O under the
282297-- surface, and therefore all typical warnings regarding lazy I/O apply.
283298--