Refactor out the HttpURLConnection logic so we can isolate the HTTP/HTTPS differences.