Skip to content

Commit a57c3fa

Browse files
upgrade to wai 3.0
1 parent 9fe6e14 commit a57c3fa

File tree

3 files changed

+16
-11
lines changed

3 files changed

+16
-11
lines changed

SocketIO.cabal

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,9 @@ library
7777
, ansi-terminal >=0.6 && <1.0
7878
, unordered-containers >=0.2 && <1.0
7979
, random >=1.0 && <2.0
80-
, wai >=2.0 && <3.0
81-
, warp >=2.0 && <3.0
80+
, wai >=3.0 && <4.0
81+
, wai-conduit >=3.0 && <4.0
82+
, warp >=3.0 && <4.0
8283
, http-types >=0.8 && <1.0
8384
, mtl >=2.1 && <3.0
8485
, transformers-base >=0.4 && <1.0
@@ -110,11 +111,12 @@ test-suite socketio-test
110111
, ansi-terminal >=0.6 && <1.0
111112
, unordered-containers >=0.2 && <1.0
112113
, random >=1.0 && <2.0
113-
, wai >=2.0 && <3.0
114-
, warp >=2.0 && <3.0
114+
, wai >=3.0 && <4.0
115+
, wai-conduit >=3.0 && <4.0
116+
, warp >=3.0 && <4.0
115117
, http-types >=0.8 && <1.0
116118
, mtl >=2.1 && <3.0
117119
, transformers-base >=0.4 && <1.0
118120
, monad-control >=0.3 && <1.0
119121
, lifted-base >=0.2 && <1.0
120-
, vector >=0.10 && <1.0
122+
, vector >=0.10 && <1.0

Web/SocketIO/Request.hs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import qualified Data.ByteString as B
1515
import Data.Conduit
1616
import qualified Data.Conduit.List as CL
1717
import qualified Network.Wai as Wai
18+
import qualified Network.Wai.Conduit as Wai
1819

1920
--------------------------------------------------------------------------------
2021
-- | Run!
@@ -31,7 +32,9 @@ sourceHTTPRequest request = do
3132
case (method, path) of
3233
("GET", (WithoutSession _ _)) -> yield Handshake
3334
("GET", (WithSession _ _ _ sessionID)) -> yield (Connect sessionID)
34-
("POST", (WithSession _ _ _ sessionID)) -> Wai.requestBody request $= demultiplexMessage =$= awaitForever (yield . Request sessionID)
35+
("POST", (WithSession _ _ _ sessionID)) -> do
36+
let reqSource = Wai.sourceRequestBody request
37+
reqSource $= demultiplexMessage =$= awaitForever (yield . Request sessionID)
3538
(_, (WithSession _ _ _ sessionID)) -> yield (Disconnect sessionID)
3639
_ -> error "error handling http request"
3740

@@ -71,4 +74,4 @@ toFlushBuilder = do
7174
Just b' -> do
7275
yield $ Chunk (Builder.fromByteString b')
7376
toFlushBuilder
74-
Nothing -> yield $ Flush
77+
Nothing -> yield $ Flush

Web/SocketIO/Server.hs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import Data.Conduit
2020
import Network.HTTP.Types (status200)
2121
import Network.HTTP.Types.Header (ResponseHeaders)
2222
import qualified Network.Wai as Wai
23+
import qualified Network.Wai.Conduit as Wai
2324
import qualified Network.Wai.Handler.Warp as Warp
2425

2526
--------------------------------------------------------------------------------
@@ -50,14 +51,13 @@ serverConfig port config handler = do
5051
--------------------------------------------------------------------------------
5152
-- | Wrapped as a HTTP app
5253
httpApp :: ResponseHeaders -> (Request -> IO Message) -> Wai.Application
53-
httpApp headerFields runConnection' httpRequest = liftIO $ do
54+
httpApp headerFields runConnection' httpRequest respond = do
5455

5556
let origin = lookupOrigin httpRequest
5657
let headerFields' = insertOrigin headerFields origin
57-
5858
let sourceBody = sourceHTTPRequest httpRequest $= runRequest runConnection'
5959

60-
return $ Wai.responseSource status200 headerFields' sourceBody
60+
respond $ Wai.responseSource status200 headerFields' sourceBody
6161

6262
where lookupOrigin req = case lookup "Origin" (Wai.requestHeaders req) of
6363
Just origin -> origin
@@ -102,4 +102,4 @@ defaultConfig = Configuration
102102
, heartbeatTimeout = 60
103103
, heartbeatInterval = 25
104104
, pollingDuration = 20
105-
}
105+
}

0 commit comments

Comments
 (0)