Refactor to allow pluggable HTTP client libraries