@@ -47,8 +47,10 @@ recvRequest :: Settings
4747 -> SockAddr -- ^ Peer's address.
4848 -> Source -- ^ Where HTTP request comes from.
4949 -> IO (Request
50+ ,Maybe (I.IORef Int)
5051 ,IndexedHeader) -- ^
5152 -- 'Request' passed to 'Application',
53+ -- how many bytes remain to be consumed, if known
5254 -- 'IndexedHeader' of HTTP request for internal use,
5355
5456recvRequest settings conn ii addr src = do
@@ -59,7 +61,7 @@ recvRequest settings conn ii addr src = do
5961 cl = idxhdr ! idxContentLength
6062 te = idxhdr ! idxTransferEncoding
6163 handleExpect conn httpversion expect
62− (rbody, bodyLength) <- bodyAndSource src cl te
64+ (rbody, remainingRef, bodyLength) <- bodyAndSource src cl te
6365 rbody' <- timeoutBody th rbody
6466 let req = Request {
6567 requestMethod = method
@@ -77,7 +79,7 @@ recvRequest settings conn ii addr src = do
7779 , requestHeaderHost = idxhdr ! idxHost
7880 , requestHeaderRange = idxhdr ! idxRange
7981 }
80− return (req, idxhdr)
82+ return (req, remainingRef, idxhdr)
8183 where
8284 th = threadHandle ii
8385
@@ -111,15 +113,16 @@ bodyAndSource :: Source
111113 -> Maybe HeaderValue -- ^ content length
112114 -> Maybe HeaderValue -- ^ transfer-encoding
113115 -> IO (IO ByteString
116+ ,Maybe (I.IORef Int)
114117 ,RequestBodyLength
115118 )
116119bodyAndSource src cl te
117120 | chunked = do
118121 csrc <- mkCSource src
119− return (readCSource csrc, ChunkedBody)
122+ return (readCSource csrc, Nothing, ChunkedBody)
120123 | otherwise = do
121− isrc <- mkISource src len
122− return (readISource isrc, bodyLen)
124+ isrc@(ISource _ remaining) <- mkISource src len
125+ return (readISource isrc, Just remaining, bodyLen)
123126 where
124127 len = toLength cl
125128 bodyLen = KnownLength $ fromIntegral len