Refactor to remove duplicate code from the Request and Response classes