问题
I am using google-cloud-cpp (C++ API for Google Cloud Platform functions) to create/read/write to buckets. When I am working from within the organization's firewall, I have to use a proxy to be able to connect to google cloud. I see that we can configure a proxy using the gcloud command line: gcloud config set proxy/type http gcloud config set proxy/address x.x.x.x gcloud config set proxy/port
Can I do something similar when I use google-cloud-cpp?
回答1:
If we look at the source code of the google-cloud-cpp library as found on GitHub, we seem to see that it is based on libcurl.
See: https://github.com/googleapis/google-cloud-cpp/blob/master/google/cloud/storage/internal/curl_handle.cc
Following on from the comments by @Travis Webb, we then look at the docs for libcurl and find:
https://curl.haxx.se/libcurl/c/CURLOPT_PROXY.html
This documents API that can be used to set proxy settings for programs that use libcurl. However, if we read deeper, we find a section on environment variables that declares that http_proxy and https_proxy can be set.
来源:https://stackoverflow.com/questions/58530120/is-there-a-way-to-use-an-http-proxy-for-google-cloud-cpp