examineBodyLength
= do req ← gets arRequest
len ← gets arReqBodyLength
- if reqMustHaveBody req then
+ if reqHasBody req then
-- POST and PUT requests must have an entity body.
when (isNothing len)
$ setStatus LengthRequired
module Network.HTTP.Lucu.Request
( Method(..)
, Request(..)
- , reqMustHaveBody
+ , reqHasBody
)
where
import Control.Applicative
{-# INLINE setHeaders #-}
setHeaders req hdr = req { reqHeaders = hdr }
--- |Returns 'True' iff the 'Request' must have an entity body.
-reqMustHaveBody ∷ Request → Bool
-{-# INLINEABLE reqMustHaveBody #-}
-reqMustHaveBody (reqMethod → m)
+-- |Returns 'True' iff the 'Request' would have an entity body.
+reqHasBody ∷ Request → Bool
+{-# INLINEABLE reqHasBody #-}
+reqHasBody (reqMethod → m)
| m ≡ POST = True
| m ≡ PUT = True
| otherwise = False
#endif
tid ← spawnRsrc rsrcDef ni
enqueue ctx ni
- if reqMustHaveBody arRequest then
+ if reqHasBody arRequest then
waitForReceiveBodyReq ctx ni tid input
else
acceptRequest ctx input
| n < 0 = fail ("getChunk: n must not be negative: " ⧺ show n)
| n ≡ 0 = return (∅)
| otherwise = do req ← getRequest
- if reqMustHaveBody req then
+ if reqHasBody req then
askForInput =≪ getInteraction
else
driftTo DecidingHeader *> return (∅)