10Duke Enterprise C++ Client
Loading...
Searching...
No Matches
LibcurlHTTPCall.h
1#ifndef TENDUKE_HTTP_LIBCURLHTTPCALL_H
2#define TENDUKE_HTTP_LIBCURLHTTPCALL_H
3
4#include "http/HTTPCall.h"
5#include "http/HTTPRequest.h"
6#include "http/HTTPResponse.h"
7#include "net/URLs.h"
8
9#include <curl/curl.h>
10
11namespace tenduke { namespace http { namespace curl {
12
13
18{
19public:
28 std::shared_ptr<const tenduke::http::HTTPRequest> request,
29 std::string userAgent,
30 const ::tenduke::net::URLs &urls,
31 bool blindlyTrustSSLCertificates = false,
32 bool verbose = false
33 );
34 ~LibCurlHTTPCall() override;
35
36// tenduke::http::HTTPCall interface
37public:
38 std::unique_ptr<tenduke::http::HTTPResponse> execute() override;
39
40protected:
44 virtual void setRequestBody();
45
49 virtual void setRequestHeaders();
50
54 virtual void setRequestMethod();
55
59 virtual void setUrl();
60
62 const std::shared_ptr<const tenduke::http::HTTPRequest> request;
63
65 const std::unique_ptr<CURL, decltype(curl_easy_cleanup) *> curlHandle;
66
68 struct curl_slist *curlHeaders;
69 //char curlErrorMessage[CURL_ERROR_SIZE];
70
72 const std::string userAgent;
73
76
78 bool verbose;
79private:
80 const ::tenduke::net::URLs &urls;
81};
82
83
84}}}
85
86#endif // TENDUKE_HTTP_LIBCURLHTTPCALL_H
HTTP-call which executes the request and returns HTTPResponse.
Definition HTTPCall.h:15
virtual void setRequestMethod()
Sets request method to the CURL-call.
Definition LibcurlHTTPCall.cpp:299
virtual void setRequestBody()
Sets request body to the CURL-call.
Definition LibcurlHTTPCall.cpp:308
const std::unique_ptr< CURL, decltype(curl_easy_cleanup) * > curlHandle
libcurl-handle for the request.
Definition LibcurlHTTPCall.h:65
bool verbose
If true, configure libcurl to provide verbose output.
Definition LibcurlHTTPCall.h:78
virtual void setUrl()
Sets URL to the CURL-call.
Definition LibcurlHTTPCall.cpp:289
const std::shared_ptr< const tenduke::http::HTTPRequest > request
The request.
Definition LibcurlHTTPCall.h:62
LibCurlHTTPCall(std::shared_ptr< const tenduke::http::HTTPRequest > request, std::string userAgent, const ::tenduke::net::URLs &urls, bool blindlyTrustSSLCertificates=false, bool verbose=false)
Constructs new instance.
Definition LibcurlHTTPCall.cpp:120
virtual void setRequestHeaders()
Sets request headers to the CURL-call.
Definition LibcurlHTTPCall.cpp:319
bool blindlyTrustSSLCertificates
If true, configure libcurl to blindly trust all SSL certificates.
Definition LibcurlHTTPCall.h:75
struct curl_slist * curlHeaders
libcurl header-list.
Definition LibcurlHTTPCall.h:68
std::unique_ptr< tenduke::http::HTTPResponse > execute() override
Executes the call synchronously.
Definition LibcurlHTTPCall.cpp:198
const std::string userAgent
Useragent-string to use.
Definition LibcurlHTTPCall.h:72
Implementation of HTTP-client using libcurl
Definition LibcurlHTTPCall.h:11
HTTP-related services.
Definition BadRequest.h:6
Root for classes, functions and globals of 10Duke C++ Client.
Definition APIRequest.h:4