diff --git a/ChangeLog.md b/ChangeLog.md
--- a/ChangeLog.md
+++ b/ChangeLog.md
@@ -1,5 +1,10 @@
 # ChangeLog for warp
 
+## 3.4.2
+
+* serveConnection is re-exported from the Internal module.
+  [#1007](https://github.com/yesodweb/wai/pull/1007)
+
 ## 3.4.1
 
 * Using time-manager v0.1.0, and auto-update v0.2.0.
diff --git a/Network/Wai/Handler/Warp/HTTP1.hs b/Network/Wai/Handler/Warp/HTTP1.hs
--- a/Network/Wai/Handler/Warp/HTTP1.hs
+++ b/Network/Wai/Handler/Warp/HTTP1.hs
@@ -115,7 +115,7 @@
     -> Source
     -> IO ()
 http1server settings ii conn transport app addr th istatus src =
-    loop True `UnliftIO.catchAny` handler
+    loop FirstRequest `UnliftIO.catchAny` handler
   where
     handler e
         -- See comment below referencing
@@ -154,19 +154,23 @@
                 `UnliftIO.catchAny` \e -> do
                     settingsOnException settings (Just req) e
                     -- Don't throw the error again to prevent calling settingsOnException twice.
-                    return False
+                    return CloseConnection
 
         -- When doing a keep-alive connection, the other side may just
         -- close the connection. We don't want to treat that as an
-        -- exceptional situation, so we pass in False to http1 (which
-        -- in turn passes in False to recvRequest), indicating that
+        -- exceptional situation, so we pass in SubsequentRequest to http1 (which
+        -- in turn passes in SubsequentRequest to recvRequest), indicating that
         -- this is not the first request. If, when trying to read the
         -- request headers, no data is available, recvRequest will
         -- throw a NoKeepAliveRequest exception, which we catch here
         -- and ignore. See: https://github.com/yesodweb/wai/issues/618
 
-        when keepAlive $ loop False
+        case keepAlive of
+          ReuseConnection -> loop SubsequentRequest
+          CloseConnection -> return ()
 
+data ReuseConnection = ReuseConnection | CloseConnection
+
 processRequest
     :: Settings
     -> InternalInfo
@@ -179,7 +183,7 @@
     -> Maybe (IORef Int)
     -> IndexedHeader
     -> IO ByteString
-    -> IO Bool
+    -> IO ReuseConnection
 processRequest settings ii conn app th istatus src req mremainingRef idxhdr nextBodyFlush = do
     -- Let the application run for as long as it wants
     T.pause th
@@ -226,7 +230,7 @@
             Nothing -> do
                 flushEntireBody nextBodyFlush
                 T.resume th
-                return True
+                return ReuseConnection
             Just maxToRead -> do
                 let tryKeepAlive = do
                         -- flush the rest of the request body
@@ -234,16 +238,16 @@
                         if isComplete
                             then do
                                 T.resume th
-                                return True
-                            else return False
+                                return ReuseConnection
+                            else return CloseConnection
                 case mremainingRef of
                     Just ref -> do
                         remaining <- readIORef ref
                         if remaining <= maxToRead
                             then tryKeepAlive
-                            else return False
+                            else return CloseConnection
                     Nothing -> tryKeepAlive
-        else return False
+        else return CloseConnection
 
 sendErrorResponse
     :: Settings
diff --git a/Network/Wai/Handler/Warp/Internal.hs b/Network/Wai/Handler/Warp/Internal.hs
--- a/Network/Wai/Handler/Warp/Internal.hs
+++ b/Network/Wai/Handler/Warp/Internal.hs
@@ -75,6 +75,7 @@
 
     -- * Request and response
     Source,
+    FirstRequest (..),
     recvRequest,
     sendResponse,
 
@@ -85,6 +86,7 @@
     -- * Misc
     http2server,
     withII,
+    serveConnection,
     pReadMaker,
 ) where
 
diff --git a/Network/Wai/Handler/Warp/Request.hs b/Network/Wai/Handler/Warp/Request.hs
--- a/Network/Wai/Handler/Warp/Request.hs
+++ b/Network/Wai/Handler/Warp/Request.hs
@@ -4,6 +4,7 @@
 {-# OPTIONS_GHC -fno-warn-deprecations #-}
 
 module Network.Wai.Handler.Warp.Request (
+    FirstRequest(..),
     recvRequest,
     headerLines,
     pauseTimeoutKey,
@@ -50,11 +51,13 @@
 
 ----------------------------------------------------------------
 
+-- | first request on this connection?
+data FirstRequest = FirstRequest | SubsequentRequest
+
 -- | Receiving a HTTP request from 'Connection' and parsing its header
 --   to create 'Request'.
 recvRequest
-    :: Bool
-    -- ^ first request on this connection?
+    :: FirstRequest
     -> Settings
     -> Connection
     -> InternalInfo
@@ -118,7 +121,7 @@
 
 ----------------------------------------------------------------
 
-headerLines :: Int -> Bool -> Source -> IO [ByteString]
+headerLines :: Int -> FirstRequest -> Source -> IO [ByteString]
 headerLines maxTotalHeaderLength firstRequest src = do
     bs <- readSource src
     if S.null bs
@@ -127,9 +130,9 @@
         -- lack of data as a real exception. See the http1 function in
         -- the Run module for more details.
 
-            if firstRequest
-                then throwIO ConnectionClosedByPeer
-                else throwIO NoKeepAliveRequest
+            case firstRequest of
+              FirstRequest -> throwIO ConnectionClosedByPeer
+              SubsequentRequest -> throwIO NoKeepAliveRequest
         else push maxTotalHeaderLength src (THStatus 0 0 id id) bs
 
 data NoKeepAliveRequest = NoKeepAliveRequest
diff --git a/Network/Wai/Handler/Warp/Run.hs b/Network/Wai/Handler/Warp/Run.hs
--- a/Network/Wai/Handler/Warp/Run.hs
+++ b/Network/Wai/Handler/Warp/Run.hs
@@ -386,8 +386,8 @@
         if isHTTP2 transport
             then return (True, "")
             else do
-                bs0 <- connRecv conn
-                if S.length bs0 >= 4 && "PRI " `S.isPrefixOf` bs0
+                bs0 <- recv4 ""
+                if "PRI " `S.isPrefixOf` bs0
                     then return (True, bs0)
                     else return (False, bs0)
     if settingsHTTP2Enabled settings && h2
@@ -395,6 +395,18 @@
             http2 settings ii conn transport app origAddr th bs
         else do
             http1 settings ii conn transport app origAddr th bs
+  where
+    recv4 bs0 = do
+        bs1 <- connRecv conn
+        if S.null bs1 then
+            return bs0
+          else do
+            -- In the case where bs0 is "", (<>) is called unnecessarily.
+            -- But we adopt this logic for simplicity.
+            let bs2 = bs0 <> bs1
+            if S.length bs2 >= 4
+                 then return bs2
+                 else recv4 bs2
 
 -- | Set flag FileCloseOnExec flag on a socket (on Unix)
 --
diff --git a/bench/Parser.hs b/bench/Parser.hs
--- a/bench/Parser.hs
+++ b/bench/Parser.hs
@@ -19,7 +19,7 @@
 import UnliftIO.Exception (impureThrow, throwIO)
 import Prelude hiding (lines)
 
-import Network.Wai.Handler.Warp.Request (headerLines)
+import Network.Wai.Handler.Warp.Request (FirstRequest (..), headerLines)
 import Network.Wai.Handler.Warp.Types
 
 #if MIN_VERSION_gauge(0, 2, 0)
@@ -61,7 +61,7 @@
             ]
         ]
   where
-    testIt req = producer req >>= headerLines 800 False
+    testIt req = producer req >>= headerLines 800 FirstRequest
 
 ----------------------------------------------------------------
 
diff --git a/test/RequestSpec.hs b/test/RequestSpec.hs
--- a/test/RequestSpec.hs
+++ b/test/RequestSpec.hs
@@ -70,7 +70,7 @@
     describe "headerLines" $ do
         let parseHeaderLine chunks = do
                 src <- mkSourceFunc chunks >>= mkSource
-                x <- headerLines defaultMaxTotalHeaderLength True src
+                x <- headerLines defaultMaxTotalHeaderLength FirstRequest src
                 x `shouldBe` ["Status: 200", "Content-Type: text/plain"]
 
         it "can handle a normal case" $
@@ -95,9 +95,9 @@
         it "can (not) handle an illegal case (1)" $ do
             let chunks = ["\nStatus:", "\n 200", "\nContent-Type: text/plain", "\r\n\r\n"]
             src <- mkSourceFunc chunks >>= mkSource
-            x <- headerLines defaultMaxTotalHeaderLength True src
+            x <- headerLines defaultMaxTotalHeaderLength FirstRequest src
             x `shouldBe` []
-            y <- headerLines defaultMaxTotalHeaderLength True src
+            y <- headerLines defaultMaxTotalHeaderLength FirstRequest src
             y `shouldBe` ["Status:", " 200", "Content-Type: text/plain"]
 
         let testLengthHeaders = ["Sta", "tus: 200\r", "\n", "Content-Type: ", "text/plain\r\n\r\n"]
@@ -106,12 +106,12 @@
         -- Length is 39, this shouldn't fail
         it "doesn't throw on correct length" $ do
             src <- mkSourceFunc testLengthHeaders >>= mkSource
-            x <- headerLines testLength True src
+            x <- headerLines testLength FirstRequest src
             x `shouldBe` ["Status: 200", "Content-Type: text/plain"]
         -- Length is still 39, this should fail
         it "throws error on correct length too long" $ do
             src <- mkSourceFunc testLengthHeaders >>= mkSource
-            headerLines (testLength - 1) True src `shouldThrow` (== OverLargeHeader)
+            headerLines (testLength - 1) FirstRequest src `shouldThrow` (== OverLargeHeader)
   where
     blankSafe = headerLinesList ["f", "oo\n", "bar\nbaz\n\r\n"]
     whiteSafe = headerLinesList ["foo\r\nbar\r\nbaz\r\n\r\n hi there"]
@@ -135,7 +135,7 @@
                     writeIORef ref z
                     return y
     src' <- mkSource src
-    res <- headerLines defaultMaxTotalHeaderLength True src'
+    res <- headerLines defaultMaxTotalHeaderLength FirstRequest src'
     return (res, src')
 
 consumeLen :: Int -> Source -> IO S8.ByteString
diff --git a/warp.cabal b/warp.cabal
--- a/warp.cabal
+++ b/warp.cabal
@@ -1,295 +1,331 @@
-Name:                warp
-Version:             3.4.1
-Synopsis:            A fast, light-weight web server for WAI applications.
-License:             MIT
-License-file:        LICENSE
-Author:              Michael Snoyman, Kazu Yamamoto, Matt Brown
-Maintainer:          michael@snoyman.com
-Homepage:            http://github.com/yesodweb/wai
-Category:            Web, Yesod
-Build-Type:          Simple
-Cabal-Version:       >= 1.10
-Stability:           Stable
-description:         HTTP\/1.0, HTTP\/1.1 and HTTP\/2 are supported.
-                     For HTTP\/2,  Warp supports direct and ALPN (in TLS)
-                     but not upgrade.
-                     API docs and the README are available at
-                     <http://www.stackage.org/package/warp>.
-extra-source-files:  attic/hex
-                     ChangeLog.md
-                     README.md
-                     test/head-response
-                     test/inputFile
+cabal-version:      >=1.10
+name:               warp
+version:            3.4.2
+license:            MIT
+license-file:       LICENSE
+maintainer:         michael@snoyman.com
+author:             Michael Snoyman, Kazu Yamamoto, Matt Brown
+stability:          Stable
+homepage:           http://github.com/yesodweb/wai
+synopsis:           A fast, light-weight web server for WAI applications.
+description:
+    HTTP\/1.0, HTTP\/1.1 and HTTP\/2 are supported.
+    For HTTP\/2,  Warp supports direct and ALPN (in TLS)
+    but not upgrade.
+    API docs and the README are available at
+    <http://www.stackage.org/package/warp>.
 
-Flag network-bytestring
-    Default: False
+category:           Web, Yesod
+build-type:         Simple
+extra-source-files:
+    attic/hex
+    ChangeLog.md
+    README.md
+    test/head-response
+    test/inputFile
 
-Flag allow-sendfilefd
-    Description: Allow use of sendfileFd (not available on GNU/kFreeBSD)
-    Default:     True
+source-repository head
+    type:     git
+    location: git://github.com/yesodweb/wai.git
 
-Flag warp-debug
-    Description: print debug output. not suitable for production
-    Default:     False
+flag network-bytestring
+    default: False
 
-Flag x509
-    Description: Adds a dependency on the x509 library to enable getting TLS client certificates.
-    Default:     True
+flag allow-sendfilefd
+    description: Allow use of sendfileFd (not available on GNU/kFreeBSD)
 
-Library
-  Build-Depends:     base                      >= 4.12       && < 5
-                   , array
-                   , auto-update               >= 0.2      && < 0.3
-                   , bsb-http-chunked                         < 0.1
-                   , bytestring                >= 0.9.1.4
-                   , case-insensitive          >= 0.2
-                   , containers
-                   , ghc-prim
-                   , hashable
-                   , http-date
-                   , http-types                >= 0.12
-                   , http2                     >= 5.1      && < 5.3
-                   , iproute                   >= 1.3.1
-                   , recv                      >= 0.1.0    && < 0.2.0
-                   , simple-sendfile           >= 0.2.7    && < 0.3
-                   , stm                       >= 2.3
-                   , streaming-commons         >= 0.1.10
-                   , text
-                   , time-manager              >= 0.1      && < 0.2
-                   , vault                     >= 0.3
-                   , wai                       >= 3.2.4    && < 3.3
-                   , word8
-                   , unliftio
-  if flag(x509)
-      Build-Depends: crypton-x509
-  if impl(ghc < 8)
-      Build-Depends: semigroups
-  if flag(network-bytestring)
-      Build-Depends: network                   >= 2.2.1.5  && < 2.2.3
-                   , network-bytestring        >= 0.1.3    && < 0.1.4
-  else
-      Build-Depends: network               >= 2.3
-  Exposed-modules:   Network.Wai.Handler.Warp
-                     Network.Wai.Handler.Warp.Internal
-  Other-modules:     Network.Wai.Handler.Warp.Buffer
-                     Network.Wai.Handler.Warp.Conduit
-                     Network.Wai.Handler.Warp.Counter
-                     Network.Wai.Handler.Warp.Date
-                     Network.Wai.Handler.Warp.FdCache
-                     Network.Wai.Handler.Warp.File
-                     Network.Wai.Handler.Warp.FileInfoCache
-                     Network.Wai.Handler.Warp.HashMap
-                     Network.Wai.Handler.Warp.HTTP1
-                     Network.Wai.Handler.Warp.HTTP2
-                     Network.Wai.Handler.Warp.HTTP2.File
-                     Network.Wai.Handler.Warp.HTTP2.PushPromise
-                     Network.Wai.Handler.Warp.HTTP2.Request
-                     Network.Wai.Handler.Warp.HTTP2.Response
-                     Network.Wai.Handler.Warp.HTTP2.Types
-                     Network.Wai.Handler.Warp.Header
-                     Network.Wai.Handler.Warp.IO
-                     Network.Wai.Handler.Warp.Imports
-                     Network.Wai.Handler.Warp.PackInt
-                     Network.Wai.Handler.Warp.ReadInt
-                     Network.Wai.Handler.Warp.Request
-                     Network.Wai.Handler.Warp.RequestHeader
-                     Network.Wai.Handler.Warp.Response
-                     Network.Wai.Handler.Warp.ResponseHeader
-                     Network.Wai.Handler.Warp.Run
-                     Network.Wai.Handler.Warp.SendFile
-                     Network.Wai.Handler.Warp.Settings
-                     Network.Wai.Handler.Warp.Types
-                     Network.Wai.Handler.Warp.Windows
-                     Network.Wai.Handler.Warp.WithApplication
-                     Paths_warp
-  Ghc-Options:       -Wall
+flag warp-debug
+    description: print debug output. not suitable for production
+    default:     False
 
-  if flag(warp-debug)
-      Cpp-Options:   -DWARP_DEBUG
-  if (os(linux) || os(freebsd) || os(darwin)) && flag(allow-sendfilefd)
-      Cpp-Options:   -DSENDFILEFD
-  if os(windows)
-      Cpp-Options:   -DWINDOWS
-      Build-Depends: time
-                   , unix-compat >= 0.2
-  else
-      Build-Depends: unix
-      Other-modules: Network.Wai.Handler.Warp.MultiMap
-  if impl(ghc >= 8)
-      Default-Extensions:  Strict StrictData
-  Default-Language:     Haskell2010
+flag x509
+    description:
+        Adds a dependency on the x509 library to enable getting TLS client certificates.
 
-Test-Suite doctest
-  buildable:            False
-  Type:                 exitcode-stdio-1.0
-  HS-Source-Dirs:       test
-  Ghc-Options:          -threaded -Wall
-  Main-Is:              doctests.hs
-  Build-Depends:        base >= 4.8 && < 5
-                      , doctest >= 0.10.1
-  if os(windows)
-    Buildable: False
-  if impl(ghc >= 8)
-      Default-Extensions:  Strict StrictData
-  Default-Language:     Haskell2010
+library
+    exposed-modules:
+        Network.Wai.Handler.Warp
+        Network.Wai.Handler.Warp.Internal
 
-Test-Suite spec
-    Main-Is:         Spec.hs
-    Other-modules:   ConduitSpec
-                     ExceptionSpec
-                     FdCacheSpec
-                     FileSpec
-                     HTTP
-                     PackIntSpec
-                     ReadIntSpec
-                     RequestSpec
-                     ResponseHeaderSpec
-                     ResponseSpec
-                     RunSpec
-                     SendFileSpec
-                     WithApplicationSpec
-                     Network.Wai.Handler.Warp
-                     Network.Wai.Handler.Warp.Buffer
-                     Network.Wai.Handler.Warp.Conduit
-                     Network.Wai.Handler.Warp.Counter
-                     Network.Wai.Handler.Warp.Date
-                     Network.Wai.Handler.Warp.FdCache
-                     Network.Wai.Handler.Warp.File
-                     Network.Wai.Handler.Warp.FileInfoCache
-                     Network.Wai.Handler.Warp.HTTP1
-                     Network.Wai.Handler.Warp.HTTP2
-                     Network.Wai.Handler.Warp.HTTP2.File
-                     Network.Wai.Handler.Warp.HTTP2.PushPromise
-                     Network.Wai.Handler.Warp.HTTP2.Request
-                     Network.Wai.Handler.Warp.HTTP2.Response
-                     Network.Wai.Handler.Warp.HTTP2.Types
-                     Network.Wai.Handler.Warp.HashMap
-                     Network.Wai.Handler.Warp.Header
-                     Network.Wai.Handler.Warp.IO
-                     Network.Wai.Handler.Warp.Imports
-                     Network.Wai.Handler.Warp.MultiMap
-                     Network.Wai.Handler.Warp.PackInt
-                     Network.Wai.Handler.Warp.ReadInt
-                     Network.Wai.Handler.Warp.Request
-                     Network.Wai.Handler.Warp.RequestHeader
-                     Network.Wai.Handler.Warp.Response
-                     Network.Wai.Handler.Warp.ResponseHeader
-                     Network.Wai.Handler.Warp.Run
-                     Network.Wai.Handler.Warp.SendFile
-                     Network.Wai.Handler.Warp.Settings
-                     Network.Wai.Handler.Warp.Types
-                     Network.Wai.Handler.Warp.Windows
-                     Network.Wai.Handler.Warp.WithApplication
-                     Paths_warp
+    other-modules:
+        Network.Wai.Handler.Warp.Buffer
+        Network.Wai.Handler.Warp.Conduit
+        Network.Wai.Handler.Warp.Counter
+        Network.Wai.Handler.Warp.Date
+        Network.Wai.Handler.Warp.FdCache
+        Network.Wai.Handler.Warp.File
+        Network.Wai.Handler.Warp.FileInfoCache
+        Network.Wai.Handler.Warp.HTTP1
+        Network.Wai.Handler.Warp.HTTP2
+        Network.Wai.Handler.Warp.HTTP2.File
+        Network.Wai.Handler.Warp.HTTP2.PushPromise
+        Network.Wai.Handler.Warp.HTTP2.Request
+        Network.Wai.Handler.Warp.HTTP2.Response
+        Network.Wai.Handler.Warp.HTTP2.Types
+        Network.Wai.Handler.Warp.HashMap
+        Network.Wai.Handler.Warp.Header
+        Network.Wai.Handler.Warp.IO
+        Network.Wai.Handler.Warp.Imports
+        Network.Wai.Handler.Warp.PackInt
+        Network.Wai.Handler.Warp.ReadInt
+        Network.Wai.Handler.Warp.Request
+        Network.Wai.Handler.Warp.RequestHeader
+        Network.Wai.Handler.Warp.Response
+        Network.Wai.Handler.Warp.ResponseHeader
+        Network.Wai.Handler.Warp.Run
+        Network.Wai.Handler.Warp.SendFile
+        Network.Wai.Handler.Warp.Settings
+        Network.Wai.Handler.Warp.Types
+        Network.Wai.Handler.Warp.Windows
+        Network.Wai.Handler.Warp.WithApplication
+        Paths_warp
 
-    Hs-Source-Dirs:  test, .
-    Type:            exitcode-stdio-1.0
+    default-language: Haskell2010
+    ghc-options:      -Wall
+    build-depends:
+        base >=4.12 && <5,
+        array,
+        auto-update >=0.2 && <0.3,
+        bsb-http-chunked <0.1,
+        bytestring >=0.9.1.4,
+        case-insensitive >=0.2,
+        containers,
+        ghc-prim,
+        hashable,
+        http-date,
+        http-types >=0.12,
+        http2 >=5.1 && <5.4,
+        iproute >=1.3.1,
+        recv >=0.1.0 && <0.2.0,
+        simple-sendfile >=0.2.7 && <0.3,
+        stm >=2.3,
+        streaming-commons >=0.1.10,
+        text,
+        time-manager >=0.1 && <0.2,
+        vault >=0.3,
+        wai >=3.2.4 && <3.3,
+        word8,
+        unliftio
 
-    Ghc-Options:     -Wall -threaded
-    Build-Tool-Depends: hspec-discover:hspec-discover
-    Build-Depends:   base >= 4.8 && < 5
-                   , QuickCheck
-                   , array
-                   , auto-update
-                   , bsb-http-chunked                         < 0.1
-                   , bytestring                >= 0.9.1.4
-                   , case-insensitive          >= 0.2
-                   , containers
-                   , directory
-                   , ghc-prim
-                   , hashable
-                   , hspec                     >= 1.3
-                   , http-client
-                   , http-date
-                   , http-types                >= 0.12
-                   , http2                     >= 5.1      && < 5.3
-                   , iproute                   >= 1.3.1
-                   , network
-                   , process
-                   , recv                      >= 0.1.0    && < 0.2.0
-                   , simple-sendfile           >= 0.2.4    && < 0.3
-                   , stm                       >= 2.3
-                   , streaming-commons         >= 0.1.10
-                   , text
-                   , time-manager
-                   , vault
-                   , wai                       >= 3.2.2.1  && < 3.3
-                   , word8
-                   , unliftio
-  if flag(x509)
-      Build-Depends: crypton-x509
-  if impl(ghc < 8)
-      Build-Depends: semigroups
-                   , transformers
+    if flag(x509)
+        build-depends: crypton-x509
 
-  if (os(linux) || os(freebsd) || os(darwin)) && flag(allow-sendfilefd)
-      Cpp-Options:   -DSENDFILEFD
-  if os(windows)
-      Cpp-Options:   -DWINDOWS
-      Build-Depends: time
-                 , unix-compat >= 0.2
-  else
-      Build-Depends: unix
-      Other-modules: Network.Wai.Handler.Warp.MultiMap
-  if impl(ghc >= 8)
-      Default-Extensions:  Strict StrictData
-  Default-Language:     Haskell2010
+    if impl(ghc <8)
+        build-depends: semigroups
 
-Benchmark parser
-    Type:           exitcode-stdio-1.0
-    Main-Is:        Parser.hs
-    other-modules:  Network.Wai.Handler.Warp.Conduit
-                    Network.Wai.Handler.Warp.Date
-                    Network.Wai.Handler.Warp.FdCache
-                    Network.Wai.Handler.Warp.FileInfoCache
-                    Network.Wai.Handler.Warp.HashMap
-                    Network.Wai.Handler.Warp.Header
-                    Network.Wai.Handler.Warp.Imports
-                    Network.Wai.Handler.Warp.MultiMap
-                    Network.Wai.Handler.Warp.ReadInt
-                    Network.Wai.Handler.Warp.Request
-                    Network.Wai.Handler.Warp.RequestHeader
-                    Network.Wai.Handler.Warp.Settings
-                    Network.Wai.Handler.Warp.Types
-                    Paths_warp
-    HS-Source-Dirs: bench .
-    Build-Depends:  base >= 4.8 && < 5
-                  , array
-                  , auto-update
-                  , bytestring
-                  , case-insensitive
-                  , containers
-                  , gauge
-                  , ghc-prim
-                  , hashable
-                  , http-date
-                  , http-types
-                  , network
-                  , network
-                  , recv
-                  , streaming-commons
-                  , text
-                  , time-manager
-                  , unliftio
-                  , vault
-                  , wai
-                  , word8
-  if flag(x509)
-      Build-Depends: crypton-x509
-  if impl(ghc < 8)
-      Build-Depends: semigroups
+    if flag(network-bytestring)
+        build-depends:
+            network >=2.2.1.5 && <2.2.3,
+            network-bytestring >=0.1.3 && <0.1.4
 
-  if (os(linux) || os(freebsd) || os(darwin)) && flag(allow-sendfilefd)
-    Cpp-Options:   -DSENDFILEFD
-    Build-Depends: unix
-  if os(windows)
-    Cpp-Options:   -DWINDOWS
-    Build-Depends: time
-                 , unix-compat >= 0.2
-  if impl(ghc >= 8)
-      Default-Extensions:  Strict StrictData
-  Default-Language:     Haskell2010
+    else
+        build-depends: network >=2.3
 
-Source-Repository head
-  Type:     git
-  Location: git://github.com/yesodweb/wai.git
+    if flag(warp-debug)
+        cpp-options: -DWARP_DEBUG
+
+    if (((os(linux) || os(freebsd)) || os(osx)) && flag(allow-sendfilefd))
+        cpp-options: -DSENDFILEFD
+
+    if os(windows)
+        cpp-options:   -DWINDOWS
+        build-depends:
+            time,
+            unix-compat >=0.2
+
+    else
+        other-modules: Network.Wai.Handler.Warp.MultiMap
+        build-depends: unix
+
+    if impl(ghc >=8)
+        default-extensions: Strict StrictData
+
+test-suite doctest
+    type:             exitcode-stdio-1.0
+    main-is:          doctests.hs
+    buildable:        False
+    hs-source-dirs:   test
+    default-language: Haskell2010
+    ghc-options:      -threaded -Wall
+    build-depends:
+        base >=4.8 && <5,
+        doctest >=0.10.1
+
+    if os(windows)
+        buildable: False
+
+    if impl(ghc >=8)
+        default-extensions: Strict StrictData
+
+test-suite spec
+    type:               exitcode-stdio-1.0
+    main-is:            Spec.hs
+    build-tool-depends: hspec-discover:hspec-discover
+    hs-source-dirs:     test .
+    other-modules:
+        ConduitSpec
+        ExceptionSpec
+        FdCacheSpec
+        FileSpec
+        HTTP
+        PackIntSpec
+        ReadIntSpec
+        RequestSpec
+        ResponseHeaderSpec
+        ResponseSpec
+        RunSpec
+        SendFileSpec
+        WithApplicationSpec
+        Network.Wai.Handler.Warp
+        Network.Wai.Handler.Warp.Internal
+        Network.Wai.Handler.Warp.Buffer
+        Network.Wai.Handler.Warp.Conduit
+        Network.Wai.Handler.Warp.Counter
+        Network.Wai.Handler.Warp.Date
+        Network.Wai.Handler.Warp.FdCache
+        Network.Wai.Handler.Warp.File
+        Network.Wai.Handler.Warp.FileInfoCache
+        Network.Wai.Handler.Warp.HTTP1
+        Network.Wai.Handler.Warp.HTTP2
+        Network.Wai.Handler.Warp.HTTP2.File
+        Network.Wai.Handler.Warp.HTTP2.PushPromise
+        Network.Wai.Handler.Warp.HTTP2.Request
+        Network.Wai.Handler.Warp.HTTP2.Response
+        Network.Wai.Handler.Warp.HTTP2.Types
+        Network.Wai.Handler.Warp.HashMap
+        Network.Wai.Handler.Warp.Header
+        Network.Wai.Handler.Warp.IO
+        Network.Wai.Handler.Warp.Imports
+        Network.Wai.Handler.Warp.PackInt
+        Network.Wai.Handler.Warp.ReadInt
+        Network.Wai.Handler.Warp.Request
+        Network.Wai.Handler.Warp.RequestHeader
+        Network.Wai.Handler.Warp.Response
+        Network.Wai.Handler.Warp.ResponseHeader
+        Network.Wai.Handler.Warp.Run
+        Network.Wai.Handler.Warp.SendFile
+        Network.Wai.Handler.Warp.Settings
+        Network.Wai.Handler.Warp.Types
+        Network.Wai.Handler.Warp.Windows
+        Network.Wai.Handler.Warp.WithApplication
+        Paths_warp
+
+    default-language:   Haskell2010
+    ghc-options:        -Wall -threaded
+    build-depends:
+        base >=4.8 && <5,
+        QuickCheck,
+        array,
+        auto-update,
+        bsb-http-chunked <0.1,
+        bytestring >=0.9.1.4,
+        case-insensitive >=0.2,
+        containers,
+        directory,
+        ghc-prim,
+        hashable,
+        hspec >=1.3,
+        http-client,
+        http-date,
+        http-types >=0.12,
+        http2 >=5.1 && <5.4,
+        iproute >=1.3.1,
+        network,
+        process,
+        recv >=0.1.0 && <0.2.0,
+        simple-sendfile >=0.2.4 && <0.3,
+        stm >=2.3,
+        streaming-commons >=0.1.10,
+        text,
+        time-manager,
+        vault,
+        wai >=3.2.2.1 && <3.3,
+        word8,
+        unliftio
+
+    if flag(x509)
+        build-depends: crypton-x509
+
+    if impl(ghc <8)
+        build-depends:
+            semigroups,
+            transformers
+
+    if (((os(linux) || os(freebsd)) || os(osx)) && flag(allow-sendfilefd))
+        cpp-options: -DSENDFILEFD
+
+    if os(windows)
+        cpp-options:   -DWINDOWS
+        build-depends:
+            time,
+            unix-compat >=0.2
+
+    else
+        other-modules: Network.Wai.Handler.Warp.MultiMap
+        build-depends: unix
+
+    if impl(ghc >=8)
+        default-extensions: Strict StrictData
+
+benchmark parser
+    type:             exitcode-stdio-1.0
+    main-is:          Parser.hs
+    hs-source-dirs:   bench .
+    other-modules:
+        Network.Wai.Handler.Warp.Conduit
+        Network.Wai.Handler.Warp.Date
+        Network.Wai.Handler.Warp.FdCache
+        Network.Wai.Handler.Warp.FileInfoCache
+        Network.Wai.Handler.Warp.HashMap
+        Network.Wai.Handler.Warp.Header
+        Network.Wai.Handler.Warp.Imports
+        Network.Wai.Handler.Warp.MultiMap
+        Network.Wai.Handler.Warp.ReadInt
+        Network.Wai.Handler.Warp.Request
+        Network.Wai.Handler.Warp.RequestHeader
+        Network.Wai.Handler.Warp.Settings
+        Network.Wai.Handler.Warp.Types
+        Paths_warp
+
+    default-language: Haskell2010
+    build-depends:
+        base >=4.8 && <5,
+        array,
+        auto-update,
+        bytestring,
+        case-insensitive,
+        containers,
+        gauge,
+        ghc-prim,
+        hashable,
+        http-date,
+        http-types,
+        network,
+        network,
+        recv,
+        streaming-commons,
+        text,
+        time-manager,
+        unliftio,
+        vault,
+        wai,
+        word8
+
+    if flag(x509)
+        build-depends: crypton-x509
+
+    if impl(ghc <8)
+        build-depends: semigroups
+
+    if (((os(linux) || os(freebsd)) || os(osx)) && flag(allow-sendfilefd))
+        cpp-options:   -DSENDFILEFD
+        build-depends: unix
+
+    if os(windows)
+        cpp-options:   -DWINDOWS
+        build-depends:
+            time,
+            unix-compat >=0.2
+
+    if impl(ghc >=8)
+        default-extensions: Strict StrictData
