diff --git a/Network/Browser.hs b/Network/Browser.hs
--- a/Network/Browser.hs
+++ b/Network/Browser.hs
@@ -115,6 +115,8 @@
        , FormVar
        ) where
 
+#include "cabal_macros.h"
+
 import Network.URI
    ( URI(..)
    , URIAuth(..)
diff --git a/Network/FastCGI.hs b/Network/FastCGI.hs
--- a/Network/FastCGI.hs
+++ b/Network/FastCGI.hs
@@ -137,6 +137,7 @@
      rsp <- handleErrors (fLog conn)
                          (handler env rq)
      writeResponse conn rsp
+     close conn
 
 -- | Takes a handler, and concurrently accepts requests from the web server
 --   by calling the handler.
diff --git a/Network/HTTP/Base.hs b/Network/HTTP/Base.hs
--- a/Network/HTTP/Base.hs
+++ b/Network/HTTP/Base.hs
@@ -722,6 +722,6 @@
       return (Response
                 { rspCode = code
                 , rspReason = reason
-                , rspHeaders = []
+                , rspHeaders = [Header HdrContentType "plain/text; charset=utf-8"]
                 , rspBody = body
                 })
diff --git a/Network/HTTP/Utils.hs b/Network/HTTP/Utils.hs
--- a/Network/HTTP/Utils.hs
+++ b/Network/HTTP/Utils.hs
@@ -40,7 +40,7 @@
 import Data.Maybe ( fromMaybe )
 import Control.Exception
 import GHC.IO.Buffer
-import GHC.IO.Encoding ( TextEncoding(..), latin1, mkTextEncoding, encode )
+import GHC.IO.Encoding ( TextEncoding(..), CodingProgress(..), latin1, mkTextEncoding, encode )
 import qualified GHC.IO.Encoding as Enc
 import qualified Data.ByteString.Internal as BS ( ByteString(..) )
 import qualified Data.ByteString.Lazy as LBS
@@ -154,10 +154,13 @@
       | isEmptyBuffer cbuf && null cs = return bss
       | otherwise = do (cbuf,cs) <- pokeElems cbuf cs
                        bbuf <- newByteBuffer max_len WriteBuffer
-                       (_,cbuf',bbuf') <- encode encoder cbuf bbuf
+                       (p,cbuf',bbuf') <- encode encoder cbuf bbuf
                        let bs = BS.PS (bufRaw bbuf')
                                       (bufL bbuf')
                                       (bufferElems bbuf')
+                           cbuf'' = case p of
+                                      InvalidSequence -> bufferRemove 1 cbuf'
+                                      _               -> cbuf'
                        convert encoder cbuf' cs (bs:bss)
       where
         pokeElems cbuf cs
diff --git a/Network/TCP.hs b/Network/TCP.hs
--- a/Network/TCP.hs
+++ b/Network/TCP.hs
@@ -145,7 +145,7 @@
       let bbuf = connByteBuf conn
           cbuf = connCharBuf conn
           size = bufferAvailable bbuf
-      bbuf <- if bufferElems bbuf == 0
+      bbuf <- if bufferElems bbuf == connChunkBits conn
                 then withBuffer bbuf $ \buf_ptr -> do
                        let ptr = buf_ptr `plusPtr` bufR bbuf
                        num <- case connSSL conn of
diff --git a/http-slim.cabal b/http-slim.cabal
--- a/http-slim.cabal
+++ b/http-slim.cabal
@@ -1,6 +1,6 @@
 Cabal-Version: >= 1.10
 Name: http-slim
-Version: 1.0
+Version: 1.2
 Build-type: Simple
 License: BSD3
 License-file: LICENSE
@@ -12,10 +12,11 @@
 Description:
   A simple HTTP client/server package with minimal dependencies
   to other packages. Most of the code is derived from 
-  the older HTTP package. FastCGI interface is included as well.
+  the older HTTP package. Server mode as well as FastCGI interface are
+  included as well.
 
 tested-with:
-  GHC==9.2.1, GHC==9.0.1,
+  GHC==9.6.6, GHC==9.2.1, GHC==9.0.1,
   GHC==8.10.7, GHC==8.8.4, GHC==8.6.5, GHC==8.4.4, GHC==8.2.2, GHC==8.0.2,
   GHC==7.10.3, GHC==7.8.4, GHC==7.6.3
 
@@ -53,7 +54,7 @@
   -- note the test harness constraints should be kept in sync with these
   -- where dependencies are shared
   build-depends:
-      base          >= 4.6.0.0   && < 4.17
+      base          >= 4.6.0.0   && < 4.22
     , array         >= 0.3.0.2   && < 0.6
     , parsec        >= 2.0       && < 3.2
     , time          >= 1.1.2.3   && < 1.13
@@ -62,10 +63,10 @@
     -- The following dependencies are refined by flags, but they should
     -- still be mentioned here on the top-level.
     , mtl           >= 2.0.0.0   && < 2.4
-    , network       >= 2.4       && < 3.2
-    , HsOpenSSL
-    , bytestring
-    , containers
+    , network       >= 2.4       && < 3.3
+    , HsOpenSSL                     < 0.12
+    , bytestring                    < 0.13
+    , containers                    < 0.8
 
   default-language: Haskell98
   default-extensions: FlexibleInstances
@@ -73,12 +74,12 @@
   if flag(network-uri)
     Build-depends: network-uri == 2.6.*, network >= 2.6
   else
-    Build-depends: network < 2.6
+    Build-depends: network < 3.3
   if flag(network-bsd)
      build-depends: network-bsd >= 2.7 && < 2.9,
                     network >= 2.7
   else
-     build-depends: network < 2.7
+     build-depends: network < 3.3
 
   if os(windows)
     Build-depends: Win32 >= 2.2.0.0 && < 2.14
