warp 3.4.21 → 3.4.22
raw patch · 5 files changed
+55/−6 lines, 5 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- ChangeLog.md +5/−0
- Network/Wai/Handler/Warp/HTTP2.hs +4/−3
- Network/Wai/Handler/Warp/HTTP2/Types.hs +4/−2
- test/HTTP2TransportSpec.hs +40/−0
- warp.cabal +2/−1
ChangeLog.md view
@@ -1,5 +1,10 @@ # ChangeLog for warp +## 3.4.22++* warp: backport total HTTP/2 transport checks to v3.4+ [#1177](https://github.com/yesodweb/wai/pull/1177)+ ## 3.4.21 Requires network 3.2.12.
Network/Wai/Handler/Warp/HTTP2.hs view
@@ -91,12 +91,13 @@ -- on it. checkTLS = case transport of TCP -> return True -- direct- tls- | tls12orLater tls -> return True+ TLS{tlsMajorVersion = major, tlsMinorVersion = minor}+ | major == 3 && minor >= 3 -> return True | otherwise -> do goaway conn H2.InadequateSecurity "Weak TLS" return False- tls12orLater tls = tlsMajorVersion tls == 3 && tlsMinorVersion tls >= 3+ -- QUIC establishes TLS 1.3 itself and uses the HTTP/3 entry point.+ QUIC{} -> return True -- | Converting WAI application to the server type of http2 library. --
Network/Wai/Handler/Warp/HTTP2/Types.hs view
@@ -15,11 +15,13 @@ isHTTP2 :: Transport -> Bool isHTTP2 TCP = False-isHTTP2 tls = useHTTP2+isHTTP2 TLS{tlsNegotiatedProtocol = protocol} = useHTTP2 where- useHTTP2 = case tlsNegotiatedProtocol tls of+ useHTTP2 = case protocol of Nothing -> False Just proto -> "h2" `BS.isPrefixOf` proto+-- QUIC uses the HTTP/3 entry point, not HTTP/2 ALPN dispatch.+isHTTP2 QUIC{} = False ----------------------------------------------------------------
+ test/HTTP2TransportSpec.hs view
@@ -0,0 +1,40 @@+{-# LANGUAGE CPP #-}+{-# LANGUAGE OverloadedStrings #-}++module HTTP2TransportSpec (spec) where++import Data.ByteString (ByteString)+import Network.Wai.Handler.Warp.HTTP2.Types (isHTTP2)+import Network.Wai.Handler.Warp.Types (Transport (..))+import Test.Hspec++spec :: Spec+spec = describe "HTTP/2 ALPN transport dispatch" $ do+ it "leaves plain TCP to prior-knowledge detection" $+ isHTTP2 TCP `shouldBe` False+ it "does not select HTTP/2 without TLS ALPN" $+ isHTTP2 (tls Nothing) `shouldBe` False+ it "does not select HTTP/2 for HTTP/1.1 ALPN" $+ isHTTP2 (tls (Just "http/1.1")) `shouldBe` False+ it "selects HTTP/2 for h2 ALPN" $+ isHTTP2 (tls (Just "h2")) `shouldBe` True+ it "preserves the existing h2 prefix behavior" $+ isHTTP2 (tls (Just "h2-14")) `shouldBe` True+ it "does not use the HTTP/2 ALPN path for QUIC" $+ isHTTP2 (quic (Just "h3")) `shouldBe` False+ it "does not inspect TLS fields for QUIC without ALPN" $+ isHTTP2 (quic Nothing) `shouldBe` False+ it "does not treat QUIC with an h2 label as TLS" $+ isHTTP2 (quic (Just "h2")) `shouldBe` False++tls :: Maybe ByteString -> Transport+tls protocol = TLS 3 3 protocol 0+#ifdef MIN_VERSION_crypton_x509+ Nothing+#endif++quic :: Maybe ByteString -> Transport+quic protocol = QUIC protocol 0+#ifdef MIN_VERSION_crypton_x509+ Nothing+#endif
warp.cabal view
@@ -1,6 +1,6 @@ cabal-version: >=1.10 name: warp-version: 3.4.21+version: 3.4.22 license: MIT license-file: LICENSE maintainer: michael@snoyman.com@@ -190,6 +190,7 @@ GracefulShutdownSpec HTTP HTTP2Spec+ HTTP2TransportSpec PackIntSpec ReadIntSpec RequestSpec