httpd: some code refactoring