websockets 0.5.2.1 → 0.6.0.0
raw patch · 6 files changed
+17/−12 lines, 6 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Network.WebSockets: requestHttpSecure :: RequestHttpPart -> Bool
- Network.WebSockets: RequestHttpPart :: !ByteString -> Headers -> RequestHttpPart
+ Network.WebSockets: RequestHttpPart :: !ByteString -> Headers -> Bool -> RequestHttpPart
- Network.WebSockets: runWebSocketsHandshake :: Protocol p => (Request -> WebSockets p a) -> Iteratee ByteString IO () -> Iteratee ByteString IO a
+ Network.WebSockets: runWebSocketsHandshake :: Protocol p => Bool -> (Request -> WebSockets p a) -> Iteratee ByteString IO () -> Iteratee ByteString IO a
- Network.WebSockets: runWebSocketsWithHandshake :: Protocol p => WebSocketsOptions -> (Request -> WebSockets p a) -> Iteratee ByteString IO () -> Iteratee ByteString IO a
+ Network.WebSockets: runWebSocketsWithHandshake :: Protocol p => WebSocketsOptions -> Bool -> (Request -> WebSockets p a) -> Iteratee ByteString IO () -> Iteratee ByteString IO a
Files
- src/Network/WebSockets/Handshake/Http.hs +5/−3
- src/Network/WebSockets/Monad.hs +5/−3
- src/Network/WebSockets/Protocol/Hybi00/Internal.hs +3/−2
- src/Network/WebSockets/Protocol/Hybi10/Internal.hs +1/−1
- src/Network/WebSockets/Socket.hs +2/−2
- websockets.cabal +1/−1
src/Network/WebSockets/Handshake/Http.hs view
@@ -15,7 +15,7 @@ import Data.Dynamic (Typeable) import Data.Monoid (mappend, mconcat)-import Control.Applicative ((<$>), (<*>), (*>), (<*))+import Control.Applicative (pure, (<$>), (<*>), (*>), (<*)) import Control.Exception (Exception) import Control.Monad.Error (Error (..)) @@ -34,6 +34,7 @@ data RequestHttpPart = RequestHttpPart { requestHttpPath :: !B.ByteString , requestHttpHeaders :: Headers+ , requestHttpSecure :: Bool } deriving (Eq, Show) -- | Full request type@@ -82,10 +83,11 @@ getSecWebSocketVersion p = lookup "Sec-WebSocket-Version" (requestHttpHeaders p) -- | Parse an initial request-decodeRequest :: A.Parser RequestHttpPart-decodeRequest = RequestHttpPart+decodeRequest :: Bool -> A.Parser RequestHttpPart+decodeRequest isSecure = RequestHttpPart <$> requestLine <*> A.manyTill header newline+ <*> pure isSecure where space = A.word8 (c2w ' ') newline = A.string "\r\n"
src/Network/WebSockets/Monad.hs view
@@ -80,7 +80,8 @@ -- | Receives the initial client handshake, then behaves like 'runWebSockets'. runWebSocketsHandshake :: Protocol p- => (Request -> WebSockets p a)+ => Bool+ -> (Request -> WebSockets p a) -> Iteratee ByteString IO () -> Iteratee ByteString IO a runWebSocketsHandshake = runWebSocketsWithHandshake defaultWebSocketsOptions@@ -89,11 +90,12 @@ -- 'runWebSocketsWith'. runWebSocketsWithHandshake :: Protocol p => WebSocketsOptions+ -> Bool -> (Request -> WebSockets p a) -> Iteratee ByteString IO () -> Iteratee ByteString IO a-runWebSocketsWithHandshake opts goWs outIter = do- httpReq <- receiveIteratee decodeRequest+runWebSocketsWithHandshake opts isSecure goWs outIter = do+ httpReq <- receiveIteratee $ decodeRequest isSecure runWebSocketsWith opts httpReq goWs outIter -- | Run a 'WebSockets' application on an 'Enumerator'/'Iteratee' pair, given
src/Network/WebSockets/Protocol/Hybi00/Internal.hs view
@@ -70,7 +70,7 @@ handshakeHybi00 :: Monad m => RequestHttpPart -> E.Iteratee B.ByteString m Request-handshakeHybi00 reqHttp@(RequestHttpPart path h) = do+handshakeHybi00 reqHttp@(RequestHttpPart path h isSecure) = do keyPart3 <- A.iterParser $ A.take 8 keyPart1 <- numberFromToken =<< getHeader "Sec-WebSocket-Key1" keyPart2 <- numberFromToken =<< getHeader "Sec-WebSocket-Key2"@@ -81,8 +81,9 @@ host <- getHeader "Host" -- todo: origin right? (also applies to hybi10) origin <- getHeader "Origin"+ let schema = if isSecure then "wss://" else "ws://" let response = response101- [ ("Sec-WebSocket-Location", B.concat ["ws://", host, path])+ [ ("Sec-WebSocket-Location", B.concat [schema, host, path]) , ("Sec-WebSocket-Origin", origin) ] key
src/Network/WebSockets/Protocol/Hybi10/Internal.hs view
@@ -140,7 +140,7 @@ handshakeHybi10 :: Monad m => RequestHttpPart -> E.Iteratee ByteString m Request-handshakeHybi10 reqHttp@(RequestHttpPart path h) = do+handshakeHybi10 reqHttp@(RequestHttpPart path h _) = do key <- getHeader "Sec-WebSocket-Key" let hash = unlazy $ bytestringDigest $ sha1 $ lazy $ key `mappend` guid let encoded = B64.encode hash
src/Network/WebSockets/Socket.hs view
@@ -59,8 +59,8 @@ runWithSocket :: Protocol p => Socket -> (Request -> WebSockets p a) -> IO a runWithSocket s ws = do- r <- E.run $ SE.enumSocket 4096 s $$- runWebSocketsWithHandshake defaultWebSocketsOptions ws (iterSocket s)+ r <- E.run $ SE.enumSocket 4096 s $$ runWebSocketsWithHandshake+ defaultWebSocketsOptions False ws (iterSocket s) S.sClose s either (error . show) return r
websockets.cabal view
@@ -1,5 +1,5 @@ Name: websockets-Version: 0.5.2.1+Version: 0.6.0.0 Synopsis: A sensible and clean way to write WebSocket-capable servers in Haskell.