Refactored HttpRequest to make it more testable