move HTTP request handling to separate file