azure-core
curl_transport.hpp
Go to the documentation of this file.
1 // Copyright (c) Microsoft Corporation. All rights reserved.
2 // SPDX-License-Identifier: MIT
3 
9 #pragma once
10 
11 #include "azure/core/context.hpp"
12 #include "azure/core/http/http.hpp"
15 
16 namespace Azure { namespace Core { namespace Http {
17  class CurlNetworkConnection;
18 
19  namespace _detail {
25  constexpr std::chrono::milliseconds DefaultConnectionTimeout = std::chrono::minutes(5);
26  } // namespace _detail
27 
36  {
45 
55 
67  };
68 
73  {
88 
99 
121  std::string CAInfo;
122 
133  bool HttpKeepAlive = true;
134 
143  bool SslVerifyPeer = true;
144 
153 
162  bool NoSignal = false;
163 
172  std::chrono::milliseconds ConnectionTimeout = _detail::DefaultConnectionTimeout;
173 
177  bool EnableCurlTracing = false;
178  };
179 
183  class CurlTransport : public HttpTransport {
184  private:
185  CurlTransportOptions m_options;
186 
191  virtual void OnUpgradedConnection(std::unique_ptr<CurlNetworkConnection>&&){};
192 
193  public:
199  CurlTransport(CurlTransportOptions const& options = CurlTransportOptions()) : m_options(options)
200  {
201  }
202 
209 
218  virtual ~CurlTransport() = default;
219 
228  std::unique_ptr<RawResponse> Send(Request& request, Context const& context) override;
229  };
230 
231 }}} // namespace Azure::Core::Http
A context is a node within a tree that represents deadlines and key/value pairs.
Definition: context.hpp:45
Concrete implementation of an HTTP Transport that uses libcurl.
Definition: curl_transport.hpp:183
CurlTransport(CurlTransportOptions const &options=CurlTransportOptions())
Construct a new CurlTransport object.
Definition: curl_transport.hpp:199
virtual ~CurlTransport()=default
Destroys a CurlTransport object.
std::unique_ptr< RawResponse > Send(Request &request, Context const &context) override
Implements interface to send an HTTP Request and produce an HTTP RawResponse.
Definition: curl.cpp:339
Base class for all HTTP transport implementations.
Definition: transport.hpp:19
A request message from a client to a server.
Definition: http.hpp:176
Context for canceling long running operations.
HTTP request and response functionality.
Azure SDK abstractions.
Definition: azure_assert.hpp:55
HTTP transport policies, and their options.
Set the libcurl connection options like a proxy and CA path.
Definition: curl_transport.hpp:73
bool SslVerifyPeer
This option determines whether libcurl verifies the authenticity of the peer's certificate.
Definition: curl_transport.hpp:143
bool HttpKeepAlive
All HTTP requests will keep the connection channel open to the service.
Definition: curl_transport.hpp:133
Azure::Nullable< std::string > ProxyUsername
Username to be used for proxy connections.
Definition: curl_transport.hpp:98
CurlTransportSslOptions SslOptions
Define the SSL options for the libcurl handle.
Definition: curl_transport.hpp:152
std::string CAInfo
Path to a PEM encoded file containing the certificate authorities sent to libcurl handle directly.
Definition: curl_transport.hpp:121
Azure::Nullable< std::string > ProxyPassword
Password to be used for proxy connections.
Definition: curl_transport.hpp:110
bool EnableCurlTracing
If set, integrates libcurl's internal tracing with Azure logging.
Definition: curl_transport.hpp:177
bool NoSignal
When true, libcurl will not use any functions that install signal handlers or any functions that caus...
Definition: curl_transport.hpp:162
Azure::Nullable< std::string > Proxy
The string for the proxy is passed directly to the libcurl handle without any parsing.
Definition: curl_transport.hpp:87
std::chrono::milliseconds ConnectionTimeout
Contain the maximum time that you allow the connection phase to the server to take.
Definition: curl_transport.hpp:172
The available options to set libcurl SSL options.
Definition: curl_transport.hpp:36
bool AllowFailedCrlRetrieval
This option allows SSL connections to proceed even if there is an error retrieving the Certificate Re...
Definition: curl_transport.hpp:54
std::string PemEncodedExpectedRootCertificates
A set of PEM encoded X.509 certificates and CRLs describing the certificates used to validate the ser...
Definition: curl_transport.hpp:66
bool EnableCertificateRevocationListCheck
This option can enable the revocation list check.
Definition: curl_transport.hpp:44
HTTP transport options parameterize the HTTP transport adapter being used.
Definition: policy.hpp:138
Utilities to be used by HTTP transport implementations.