@@ -18,6 +18,7 @@
18{-# LANGUAGE UndecidableInstances #-}
18{-# LANGUAGE UndecidableInstances #-}
19{-# OPTIONS_GHC -fcontext-stack=100 #-}
19{-# OPTIONS_GHC -fcontext-stack=100 #-}
20{-# OPTIONS_GHC -fno-warn-orphans #-}
20{-# OPTIONS_GHC -fno-warn-orphans #-}
21+{-# OPTIONS_GHC -fno-warn-name-shadowing #-}
22module Servant.ClientSpec where
23module Servant.ClientSpec where
@@ -25,22 +26,26 @@ module Servant.ClientSpec where
25import Control.Applicative ((<$>))
26import Control.Applicative ((<$>))
27import Control.Arrow (left)
28import Control.Arrow (left)
28−import Control.Concurrent
29+import Control.Concurrent (forkIO, killThread, newEmptyMVar,
29−import Control.Exception
31+import Control.Exception (bracket, finally)
30−import Control.Monad.Trans.Except
32+import Control.Monad.Trans.Except (ExceptT, runExceptT, throwE)
31import Data.Aeson
33import Data.Aeson
32import Data.Char
34import Data.Char
35+import Data.Char (chr, isPrint)
33import Data.Foldable (forM_)
36import Data.Foldable (forM_)
34import Data.Monoid hiding (getLast)
37import Data.Monoid hiding (getLast)
35import Data.Proxy
38import Data.Proxy
36import qualified Data.Text as T
39import qualified Data.Text as T
37−import GHC.Generics
40+import GHC.Generics (Generic)
38import GHC.TypeLits
41import GHC.TypeLits
39import qualified Network.HTTP.Client as C
42import qualified Network.HTTP.Client as C
40import Network.HTTP.Media
43import Network.HTTP.Media
41−import Network.HTTP.Types hiding (Header)
44+import Network.HTTP.Types (Method, Status (..), badRequest400,
46+import qualified Network.HTTP.Types as HTTP
42import Network.Socket
47import Network.Socket
43−import Network.Wai hiding (Response)
48+import Network.Wai (Application, responseLBS)
44import Network.Wai.Handler.Warp
49import Network.Wai.Handler.Warp
45import System.IO.Unsafe (unsafePerformIO)
50import System.IO.Unsafe (unsafePerformIO)
46import Test.Hspec
51import Test.Hspec
@@ -117,7 +122,7 @@ server = serve api (
117 :<|> return
122 :<|> return
118 :<|> (\ name -> case name of
123 :<|> (\ name -> case name of
119 Just "alice" -> return alice
124 Just "alice" -> return alice
120− Just name -> throwE $ ServantErr 400 (name ++ " not found") "" []
125+ Just n -> throwE $ ServantErr 400 (n ++ " not found") "" []
121 Nothing -> throwE $ ServantErr 400 "missing parameter" "" [])
126 Nothing -> throwE $ ServantErr 400 "missing parameter" "" [])
122 :<|> (\ names -> return (zipWith Person names [0..]))
127 :<|> (\ names -> return (zipWith Person names [0..]))
123 :<|> return
128 :<|> return