Remove duplicated code in HTTP