34 #include "../Exception.h"    35 #include "../Managers/FileDescriptorManager.h"    36 #include "../Encoding/Http.h"    48   int32_t _responseCode = -1;
    98   HttpClient(
BaseLib::SharedObjects *baseLib, std::string hostname, int32_t port = 80, 
bool keepAlive = 
true, 
bool useSSL = 
false, std::string caFile = 
"", 
bool verifyCertificate = 
true, std::string certPath = 
"", std::string keyPath = 
"");
   117              std::string hostname,
   121              bool verifyCertificate,
   124              std::string certPath,
   125              std::string certData,
   138   std::shared_ptr<TcpSocket> 
getSocket() { 
return _socket; }
   144   void setTimeout(uint32_t 
value);
   146   void setVerifyHostname(
bool value);
   152   void setUserAgent(
const std::string &value);
   158   bool connected() { 
return _socket && _socket->connected(); }
   181   std::string 
getIpAddress() { 
return _socket ? _socket->getIpAddress() : 
""; }
   189   void sendRequest(
const std::string &request, std::string &response, 
bool responseIsHeaderOnly = 
false);
   197   void sendRequest(
const std::string &request, 
Http &response, 
bool responseIsHeaderOnly = 
false);
   205   void delete_(
const std::string &path, std::string &data, 
const std::string &additionalHeaders = 
"");
   213   void delete_(
const std::string &path, 
Http &data, 
const std::string &additionalHeaders = 
"");
   221   void get(
const std::string &path, std::string &data, 
const std::string &additionalHeaders = 
"");
   229   void get(
const std::string &path, 
Http &data, 
const std::string &additionalHeaders = 
"");
   238   void patch(
const std::string &path, std::string &dataIn, std::string &dataOut, 
const std::string &additionalHeaders = 
"");
   247   void patch(
const std::string &path, std::string &dataIn, 
Http &dataOut, 
const std::string &additionalHeaders = 
"");
   256   void post(
const std::string &path, std::string &dataIn, std::string &dataOut, 
const std::string &additionalHeaders = 
"");
   265   void post(
const std::string &path, std::string &dataIn, 
Http &dataOut, 
const std::string &additionalHeaders = 
"");
   274   void put(
const std::string &path, std::string &dataIn, std::string &dataOut, 
const std::string &additionalHeaders = 
"");
   283   void put(
const std::string &path, std::string &dataIn, 
Http &dataOut, 
const std::string &additionalHeaders = 
"");
   305   std::string _hostname = 
"";
   315   bool _keepAlive = 
true;
   320   bool _keepRawContent = 
false;
   322   std::string _userAgent = 
"Homegear";
 std::vector< char > & getRawContent()
Returns the raw content. 
Definition: HttpClient.h:175
This is the base library main class. 
Definition: BaseLib.h:95
Exception class for timeouts of the HTTP client. 
Definition: HttpClient.h:73
std::vector< char > _rawContent
Stores the raw response. 
Definition: HttpClient.h:327
void enableRawContent(bool value)
Enables storage of raw content. 
Definition: HttpClient.h:169
The class only makes sure that the vector is not copyable and the data is zeroed on destruction...
Definition: Io.h:40
Definition: BaseLib.cpp:34
HttpClientTimeOutException(const std::string &message)
Definition: HttpClient.h:64
HttpClientSocketClosedException(const std::string &message)
Definition: HttpClient.h:75
int32_t responseCode() const
Definition: HttpClient.h:53
PVariable value
Definition: UiElements.h:217
std::shared_ptr< TcpSocket > getSocket()
Returns the underlying TcpSocket. 
Definition: HttpClient.h:138
std::mutex _socketMutex
Protects _socket to only allow one operation at a time. 
Definition: HttpClient.h:295
HttpClientException(const std::string &message)
Definition: HttpClient.h:50
Exception class for the HTTP client. 
Definition: HttpClient.h:46
std::shared_ptr< TcpSocket > _socket
The socket object. 
Definition: HttpClient.h:300
This class provides a basic HTTP client. 
Definition: HttpClient.h:83
Exception class for timeouts of the HTTP client. 
Definition: HttpClient.h:62
std::string getIpAddress()
Returns the IP address of the HTTP server. 
Definition: HttpClient.h:181
Base class for all exceptions defined in Homegear. 
Definition: Exception.h:41
void disconnect()
Closes the socket. 
Definition: HttpClient.h:163
bool connected()
Returns "true" if the socket is connected, otherwise "false". 
Definition: HttpClient.h:158
HttpClientException(const std::string &message, int32_t responseCode)
Definition: HttpClient.h:51