improvements to HTTP logic