有没有办法为 google-cloud-cpp 使用 http 代理?

0 google-cloud-storage google-cloud-sdk google-cloud-cpp

我正在使用google-cloud-cpp(用于 Google Cloud Platform 函数的 C++ API)来创建/读取/写入存储桶。当我在组织的防火墙内工作时,我必须使用代理才能连接到谷歌云。我看到我们可以使用 gcloud 命令行配置代理: gcloud config set proxy/type http gcloud config set proxy/address xxxx gcloud config set proxy/port

当我使用 google-cloud-cpp 时,我可以做类似的事情吗?

Kol*_*ban 5

如果我们查看在 GitHub 上找到的 google-cloud-cpp 库的源代码,我们似乎会看到它是基于 libcurl 的。

请参阅:https : //github.com/googleapis/google-cloud-cpp/blob/master/google/cloud/storage/internal/curl_handle.cc

继@Travis Webb 的评论之后,我们查看 libcurl 的文档并发现:

https://curl.haxx.se/libcurl/c/CURLOPT_PROXY.html

此文档可用于为使用 libcurl 的程序设置代理设置的 API。但是,如果我们深入阅读,我们会找到有关环境变量的部分,该部分声明http_proxyhttps_proxy可以设置。