10Duke Enterprise C++ SDK
Loading...
Searching...
No Matches
tenduke::http::curl::LibCurlHTTPCall Class Reference

#include <LibcurlHTTPCall.h>

Detailed Description

LibCurl-based implementation of tenduke::http::HTTPCall.

Inheritance diagram for tenduke::http::curl::LibCurlHTTPCall:
tenduke::http::HTTPCall

Public Member Functions

 LibCurlHTTPCall (std::shared_ptr< const tenduke::http::HTTPRequest > request, std::string userAgent, const ::tenduke::net::URLs &urls, bool verbose=false, std::size_t maxResponseBodySize=DEFAULT_MAX_RESPONSE_BODY_SIZE)
 Constructs new instance.
std::unique_ptr< tenduke::http::HTTPResponse > execute () override
 Executes the call synchronously.

Protected Member Functions

virtual void setRequestBody ()
 Sets request body to the CURL-call.
virtual void setRequestHeaders ()
 Sets request headers to the CURL-call.
virtual void setRequestMethod ()
 Sets request method to the CURL-call.
virtual void restrictProtocols ()
 Restricts the CURL-call to protocols http and https, without following redirects.
virtual void configureTLS ()
 Enables TLS certificate verification of the CURL-call: the certificate chain and the host name are verified.
virtual void setUrl ()
 Sets URL to the CURL-call.

Protected Attributes

const std::shared_ptr< const tenduke::http::HTTPRequest > request
 The request.
const std::unique_ptr< CURL, decltype(curl_easy_cleanup) * > curlHandle
 libcurl-handle for the request.
struct curl_slist * curlHeaders
 libcurl header-list.
const std::string userAgent
 Useragent-string to use.
bool verbose
 If true, configure libcurl to provide verbose output.
const std::size_t maxResponseBodySize
 Maximum size of the response body in bytes.

Constructor & Destructor Documentation

◆ LibCurlHTTPCall()

tenduke::http::curl::LibCurlHTTPCall::LibCurlHTTPCall ( std::shared_ptr< const tenduke::http::HTTPRequest > request,
std::string userAgent,
const ::tenduke::net::URLs & urls,
bool verbose = false,
std::size_t maxResponseBodySize = DEFAULT_MAX_RESPONSE_BODY_SIZE )

Constructs new instance.

Parameters
request-
userAgent-
urls-
verbose-
maxResponseBodySizemaximum size of the response body in bytes, a larger response is aborted

Member Function Documentation

◆ configureTLS()

void tenduke::http::curl::LibCurlHTTPCall::configureTLS ( )
protectedvirtual

Enables TLS certificate verification of the CURL-call: the certificate chain and the host name are verified.

On Windows, the CA certificates of the Windows certificate store are used.

Exceptions
tenduke::http::HTTPRequestExceptionif libcurl does not accept the configuration

◆ execute()

std::unique_ptr< xdhttp::HTTPResponse > tenduke::http::curl::LibCurlHTTPCall::execute ( )
overridevirtual

Executes the call synchronously.

NOTE: This is blocking call.

Returns
HTTP-response.
Exceptions
tenduke::net::NetworkingException(or subclasses) when the call fails for various networking reasons like "no such host", "network timeout", "networking connection broken" and so on. Some of these are transient and thus re-triable, some indicate configuration error.
tenduke::net::HTTPRequestExceptionwhen the call fails for various reasons, see documentation for the exception for details. NOTE HTTPCall does not throw exception if the request technically succeeds, but the server returns HTTP status code >= 400. It is responsibility of the caller to interpret the status code and act accordingly.

Implements tenduke::http::HTTPCall.

◆ restrictProtocols()

void tenduke::http::curl::LibCurlHTTPCall::restrictProtocols ( )
protectedvirtual

Restricts the CURL-call to protocols http and https, without following redirects.

Exceptions
tenduke::http::HTTPRequestExceptionif libcurl does not accept the restriction

◆ setRequestHeaders()

void tenduke::http::curl::LibCurlHTTPCall::setRequestHeaders ( )
protectedvirtual

Sets request headers to the CURL-call.

Exceptions
tenduke::http::HTTPRequestExceptionif a header name or value is not valid, e.g. contains CR or LF

The documentation for this class was generated from the following files:
  • core/services/default/src/http/LibcurlHTTPCall.h
  • core/services/default/src/http/LibcurlHTTPCall.cpp