13 #include <curl/curl.h>
73 curl_slist * internalHeader;
75 std::string lastErrorStr;
76 std::string responseBuffer;
77 std::string responseHeaders;
78 const char* writeBuffer;
79 unsigned int currentWriteOffset;
82 static size_t readResponse (
void* ptr,
size_t size,
size_t nmemb,
HttpSession* curl);
83 static size_t readResponseHeaders (
void* ptr,
size_t size,
size_t nmemb,
HttpSession* curl);
84 static size_t writeData (
void* ptr,
size_t size,
size_t nmemb,
HttpSession* curl);
85 static int writeSeek(
HttpSession *curl, curl_off_t offset,
int origin);
87 static int printTrace (CURL* curl, curl_infotype type,
char* data,
size_t size,
void* userp);
163 typedef std::vector<std::pair<std::string, std::string> >
Headers;
170 void appendHeader(
const std::string& key,
const std::string& value);
182 void setData (
const std::string& data);
206 void setURL (
const std::string& url);
212 std::string
getURL()
const;
268 void setCredentials(
const std::string& login,
const std::string& password);
315 std::string customRequestType;
319 bool redirectionEnabled;
321 std::string response;
323 std::string errorString;
324 bool basicAuthenticationEnabled;
325 bool digestAuthenticationEnabled;
327 std::string password;
void setResponseHeaders(const std::string &headers)
Sets response headers data.
Definition: Http.cpp:150
bool digestHttpAuthenticationEnabled()
Checks if digest HTTP authentication is enabled.
Definition: Http.cpp:123
std::string getURL() const
Definition: Http.cpp:95
void enableDigestHttpAuthentication(bool enable)
Enables or disables digest HTTP authentication.
Definition: Http.cpp:114
Headers getResponseHeaders() const
Gets response headers.
Definition: Http.cpp:168
HttpSession class. Allows to send Http requests.
Definition: Http.hpp:26
void setResponseCode(long code)
Sets request response code.
Definition: Http.cpp:173
void setFollowRedirection(bool follow)
Should redirections be followed.
Definition: Http.cpp:80
void enableBasicHttpAuthentication(bool enable)
Enables or disables basic HTTP authentication.
Definition: Http.cpp:100
HttpAuthorizer interface. This should be used by classes implementing different Http authorization me...
Definition: Http.hpp:334
std::vector< std::pair< std::string, std::string > > Headers
Definition: Http.hpp:163
bool execute(HttpMessage *msg)
Executes given http message. After executing message object will be updated with response, response code etc.
Definition: Http.cpp:288
RequestType getRequestType() const
Returns currently set request type.
Definition: Http.cpp:49
bool followRedirection() const
Returns status of redirections.
Definition: Http.cpp:85
void setData(const std::string &data)
Sets body of message.
Definition: Http.cpp:70
std::string getData() const
Definition: Http.cpp:75
void cleanup()
Cleans up http session.
Definition: Http.cpp:257
void setResponse(const std::string &response)
Sets response data.
Definition: Http.cpp:140
const Headers & getHeaders() const
Returns all headers set for message.
Definition: Http.cpp:65
void getCredentials(std::string &login, std::string &password)
Gets credential for HTTP authentication.
Definition: Http.cpp:134
~HttpMessage()
Destructor, virtual by default.
Definition: Http.cpp:30
bool init()
Initializes http session.
Definition: Http.cpp:238
virtual bool authorizeMessage(HttpMessage *msg)=0
Authorizes message.
std::string getResponse() const
Gets request response.
Definition: Http.cpp:145
void setRequestType(RequestType type)
Sets message request type.
Definition: Http.cpp:35
static std::string responseCodeDescription(long code)
Definition: Http.cpp:193
ResponseCode
Definition: Http.hpp:119
void appendHeader(const std::string &key, const std::string &value)
Appends given header to message headers.
Definition: Http.cpp:59
HttpSession()
Constructor.
Definition: Http.cpp:224
long getResponseCode() const
Gets request response code.
Definition: Http.cpp:178
virtual ~HttpSession()
Destructor, virtual by default.
Definition: Http.cpp:233
void setURL(const std::string &url)
Sets URL of message.
Definition: Http.cpp:90
std::string getCustomRequestType() const
Returns custom request type, if request type is set to RequestType::CUSTOM.
Definition: Http.cpp:54
bool basicHttpAuthenticationEnabled()
Checks if basic HTTP authentication is enabled.
Definition: Http.cpp:109
virtual ~HttpAuthorizer()
Destructor, virtual by default.
Definition: Http.hpp:340
void setCredentials(const std::string &login, const std::string &password)
Sets credentials for HTTP authentication.
Definition: Http.cpp:128
HttpMessage()
Constructor.
Definition: Http.cpp:20
void setErrorString(const std::string &errorStr)
Sets error description.
Definition: Http.cpp:183
HttpMessage class. Represents Http request that can be executed using HttpSession object...
Definition: Http.hpp:95
void enableTrace(bool enabled)
Definition: Http.cpp:283
RequestType
Definition: Http.hpp:111
std::string getErrorString() const
Gets error description.
Definition: Http.cpp:188