@@ -18,18 +18,19 @@ module Network.Wai.Test
1818import Network.Wai
1919import qualified Test.HUnit.Base as H
2020import Control.Monad.IO.Class (liftIO)
21−import Control.Monad.Trans.Class (lift)
22−import Control.Monad.Trans.State (StateT, evalStateT, get, put)
21+import Control.Monad.Trans.State (StateT, evalStateT)
2322import Control.Monad.Trans.Reader (ReaderT, runReaderT, ask)
2423import Data.Map (Map)
2524import qualified Data.Map as Map
2625import Data.ByteString (ByteString)
27−import qualified Data.ByteString as S
2826import qualified Data.ByteString.Char8 as S8
29−import Data.Enumerator (joinI, consume, ($$), run_, enumList)
27+import Data.Enumerator (joinI, ($$), run_, enumList)
28+import Data.Enumerator.List (consume)
3029import Blaze.ByteString.Builder.Enumerator (builderToByteString)
3130import qualified Data.ByteString.Lazy as L
3231import qualified Data.ByteString.Lazy.Char8 as L8
32+import qualified Network.HTTP.Types as H
33+import qualified Data.Ascii as A
3334
3435type Session = ReaderT Application (StateT ClientState IO)
3536
@@ -48,8 +49,8 @@ data SRequest = SRequest
4849 , simpleRequestBody :: L.ByteString
4950 }
5051data SResponse = SResponse
51− { simpleStatus :: Status
52− , simpleHeaders :: [(CIByteString, ByteString)]
52+ { simpleStatus :: H.Status
53+ , simpleHeaders :: H.ResponseHeaders
5354 , simpleBody :: L.ByteString
5455 }
5556 deriving (Show, Eq)
@@ -78,7 +79,7 @@ assertBool s b = liftIO $ H.assertBool s b
7879assertString :: String -> Session ()
7980assertString s = liftIO $ H.assertString s
8081
81−assertContentType :: ByteString -> SResponse -> Session ()
82+assertContentType :: A.Ascii -> SResponse -> Session ()
8283assertContentType ct SResponse{simpleHeaders = h} =
8384 case lookup "content-type" h of
8485 Nothing -> assertString $ concat
@@ -93,7 +94,7 @@ assertContentType ct SResponse{simpleHeaders = h} =
9394 , show ct'
9495 ]) (go ct == go ct')
9596 where
96− go = S8.takeWhile (/= ';')
97+ go = A.unsafeFromByteString . S8.takeWhile (/= ';') . A.toByteString
9798
9899assertStatus :: Int -> SResponse -> Session ()
99100assertStatus i SResponse{simpleStatus = s} = assertBool (concat
@@ -103,7 +104,7 @@ assertStatus i SResponse{simpleStatus = s} = assertBool (concat
103104 , show sc
104105 ]) $ i == sc
105106 where
106− sc = statusCode s
107+ sc = H.statusCode s
107108
108109assertBody :: L.ByteString -> SResponse -> Session ()
109110assertBody lbs SResponse{simpleBody = lbs'} = assertBool (concat
@@ -113,7 +114,7 @@ assertBody lbs SResponse{simpleBody = lbs'} = assertBool (concat
113114 , show $ L8.unpack lbs'
114115 ]) $ lbs == lbs'
115116
116−assertHeader :: CIByteString -> S.ByteString -> SResponse -> Session ()
117+assertHeader :: A.CIAscii -> A.Ascii -> SResponse -> Session ()
117118assertHeader header value SResponse{simpleHeaders = h} =
118119 case lookup header h of
119120 Nothing -> assertString $ concat
@@ -132,7 +133,7 @@ assertHeader header value SResponse{simpleHeaders = h} =
132133 , show value'
133134 ]) (value == value')
134135
135−assertNoHeader :: CIByteString -> SResponse -> Session ()
136+assertNoHeader :: A.CIAscii -> SResponse -> Session ()
136137assertNoHeader header SResponse{simpleHeaders = h} =
137138 case lookup header h of
138139 Nothing -> return ()