Rewrite HTTP module to support keep-alive; fix race condition in database.put