Refactor before hook in HTTPServer