http-server: code cleanup and refactoring