abstract code from http server code