on master help sign in
Add tests for unconsumed chunked bodies

At first I thought this was the cause of #249, but that was a mistake. But extra tests never hurt.

commit05a5add2fce87bbeb12212644e2cd27d8afdf0f5 authorMichael Snoyman <michael@snoyman.com> dateSun 20 Apr 2014, 13:49 (12 years ago) parent85f762e
1 file changed+22
warp/test/RunSpec.hs+22
warp/test/RunSpec.hs+22
@@ -135,6 +135,12 @@ singleGet = "GET / HTTP/1.1\r\nHost: localhost\r\n\r\n"
135135singlePostHello :: ByteString
136136singlePostHello = "POST /hello HTTP/1.1\r\nHost: localhost\r\nContent-length: 5\r\n\r\nHello"
137137
138+singleChunkedPostHello :: [ByteString]
139+singleChunkedPostHello =
140+ [ "POST /hello HTTP/1.1\r\nHost: localhost\r\nTransfer-Encoding: chunked\r\n\r\n"
141+ , "5\r\nHello\r\n0\r\n"
142+ ]
143+
138144spec :: Spec
139145spec = do
140146 describe "non-pipelining" $ do
@@ -148,6 +154,14 @@ spec = do
148154 [ singlePostHello
149155 , singleGet
150156 ]
157+ it "chunked body, read" $ runTest 2 readBody $ concat
158+ [ singleChunkedPostHello
159+ , [singleGet]
160+ ]
161+ it "chunked body, ignore" $ runTest 2 ignoreBody $ concat
162+ [ singleChunkedPostHello
163+ , [singleGet]
164+ ]
151165 describe "pipelining" $ do
152166 it "no body, read" $ runTest 5 readBody [S.concat $ replicate 5 singleGet]
153167 it "no body, ignore" $ runTest 5 ignoreBody [S.concat $ replicate 5 singleGet]
@@ -159,6 +173,14 @@ spec = do
159173 [ singlePostHello
160174 , singleGet
161175 ]
176+ it "chunked body, read" $ runTest 2 readBody $ return $ S.concat
177+ [ S.concat singleChunkedPostHello
178+ , singleGet
179+ ]
180+ it "chunked body, ignore" $ runTest 2 ignoreBody $ return $ S.concat
181+ [ S.concat singleChunkedPostHello
182+ , singleGet
183+ ]
162184 describe "no hanging" $ do
163185 it "has body, read" $ runTest 1 readBody $ map S.singleton $ S.unpack singlePostHello
164186 it "double connect" $ runTest 1 doubleConnect [singlePostHello]