Refactoring HTTPS requests