Writing an asynchronous HTTP server and client