|
23 | 23 | #include "google/cloud/internal/rest_options.h" |
24 | 24 | #include "google/cloud/internal/user_agent_prefix.h" |
25 | 25 | #include "google/cloud/log.h" |
| 26 | +#include "google/cloud/rest_options.h" |
26 | 27 | #include "absl/strings/match.h" |
27 | 28 | #include "absl/strings/strip.h" |
28 | 29 | #include <algorithm> |
@@ -196,6 +197,8 @@ CurlImpl::CurlImpl(CurlHandle handle, |
196 | 197 | proxy_ = CurlOptProxy(options); |
197 | 198 | proxy_username_ = CurlOptProxyUsername(options); |
198 | 199 | proxy_password_ = CurlOptProxyPassword(options); |
| 200 | + |
| 201 | + interface_ = CurlOptInterface(options); |
199 | 202 | } |
200 | 203 |
|
201 | 204 | CurlImpl::~CurlImpl() { |
@@ -319,6 +322,10 @@ Status CurlImpl::MakeRequest(HttpMethod method, RestContext& context, |
319 | 322 | status = handle_.SetOption(CURLOPT_PROXYPASSWORD, proxy_password_->c_str()); |
320 | 323 | if (!status.ok()) return OnTransferError(context, std::move(status)); |
321 | 324 | } |
| 325 | + if (interface_) { |
| 326 | + status = handle_.SetOption(CURLOPT_INTERFACE, interface_->c_str()); |
| 327 | + if (!status.ok()) return OnTransferError(context, std::move(status)); |
| 328 | + } |
322 | 329 |
|
323 | 330 | if (method == HttpMethod::kGet) { |
324 | 331 | status = handle_.SetOption(CURLOPT_NOPROGRESS, 1L); |
@@ -786,6 +793,12 @@ absl::optional<std::string> CurlOptProxyPassword(Options const& options) { |
786 | 793 | return cfg.password(); |
787 | 794 | } |
788 | 795 |
|
| 796 | +absl::optional<std::string> CurlOptInterface(Options const& options) { |
| 797 | + auto const& cfg = options.get<Interface>(); |
| 798 | + if (cfg.empty()) return absl::nullopt; |
| 799 | + return cfg; |
| 800 | +} |
| 801 | + |
789 | 802 | GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END |
790 | 803 | } // namespace rest_internal |
791 | 804 | } // namespace cloud |
|
0 commit comments