@@ -18,6 +18,8 @@ import Network.Wai.Handler.Warp.Types
18-- | Runs the given 'Application' on a free port. Passes the port to the given
18-- | Runs the given 'Application' on a free port. Passes the port to the given
19-- operation and executes it, while the 'Application' is running. Shuts down the
19-- operation and executes it, while the 'Application' is running. Shuts down the
20-- server before returning.
20-- server before returning.
21withApplication :: IO Application -> (Port -> IO a) -> IO a
23withApplication :: IO Application -> (Port -> IO a) -> IO a
22withApplication mkApp action = do
24withApplication mkApp action = do
23 app <- mkApp
25 app <- mkApp
@@ -45,6 +47,8 @@ withApplication mkApp action = do
46-- __The exception handling makes this function unsuitable for use in production.__
48-- __The exception handling makes this function unsuitable for use in production.__
47-- Use 'withApplication' instead.
49-- Use 'withApplication' instead.
48testWithApplication :: IO Application -> (Port -> IO a) -> IO a
52testWithApplication :: IO Application -> (Port -> IO a) -> IO a
49testWithApplication mkApp action = do
53testWithApplication mkApp action = do
50 callingThread <- myThreadId
54 callingThread <- myThreadId
@@ -70,6 +74,8 @@ mkWaiter = do
72-- | Opens a socket on a free port and returns both port and socket.
76-- | Opens a socket on a free port and returns both port and socket.
73openFreePort :: IO (Port, Socket)
79openFreePort :: IO (Port, Socket)
74openFreePort = do
80openFreePort = do
75 s <- socket AF_INET Stream defaultProtocol
81 s <- socket AF_INET Stream defaultProtocol