@@ -263,7 +263,14 @@ plainHTTP :: TLSSettings -> Socket -> I.IORef B.ByteString -> IO (Connection, Bo
263263plainHTTP TLSSettings{..} s cachedRef = case onInsecure of
264264 AllowInsecure -> do
265265 conn' <- socketConnection s
266− return (conn' { connRecv = getNext cachedRef s 4096 }, False)
266+ let newRecv = do
267+ bs <- I.readIORef cachedRef
268+ if B.null bs
269+ then connRecv conn'
270+ else do
271+ I.writeIORef cachedRef B.empty
272+ return bs
273+ return (conn' { connRecv = newRecv }, False)
267274 DenyInsecure lbs -> do
268275 sendAll s "HTTP/1.1 200 OK\r\nContent-Type: text/plain\r\n\r\n"
269276 mapM_ (sendAll s) $ L.toChunks lbs