OpenAB
1.0.1
|
HttpMessage class. Represents Http request that can be executed using HttpSession object. More...
#include <Http.hpp>
Public Types | |
enum | RequestType { POST = 0, GET, PUT, CUSTOM } |
enum | ResponseCode { OK = 200, CREATED = 201, ACCEPTED = 202, NO_CONTENT = 204, MULTISTATUS = 207, MOVED_PERMAMENTLY = 301, BAD_REQUEST = 400, UNAUTHORIZED = 401, FORBIDDEN = 403, NOT_FOUND = 404, PRECONDITION_FAILED = 412 } |
typedef std::vector< std::pair < std::string, std::string > > | Headers |
Public Member Functions | |
HttpMessage () | |
Constructor. More... | |
~HttpMessage () | |
Destructor, virtual by default. More... | |
void | setRequestType (RequestType type) |
Sets message request type. More... | |
void | setRequestType (const std::string &custom) |
Sets custom message request type. Automatically sets request type to RequestType::CUSTOM. More... | |
RequestType | getRequestType () const |
Returns currently set request type. More... | |
std::string | getCustomRequestType () const |
Returns custom request type, if request type is set to RequestType::CUSTOM. More... | |
void | appendHeader (const std::string &key, const std::string &value) |
Appends given header to message headers. More... | |
const Headers & | getHeaders () const |
Returns all headers set for message. More... | |
void | setData (const std::string &data) |
Sets body of message. More... | |
std::string | getData () const |
void | setFollowRedirection (bool follow) |
Should redirections be followed. More... | |
bool | followRedirection () const |
Returns status of redirections. More... | |
void | setURL (const std::string &url) |
Sets URL of message. More... | |
std::string | getURL () const |
void | setResponse (const std::string &response) |
Sets response data. More... | |
std::string | getResponse () const |
Gets request response. More... | |
void | setResponseHeaders (const std::string &headers) |
Sets response headers data. More... | |
Headers | getResponseHeaders () const |
Gets response headers. More... | |
void | setResponseCode (long code) |
Sets request response code. More... | |
long | getResponseCode () const |
Gets request response code. More... | |
void | setErrorString (const std::string &errorStr) |
Sets error description. More... | |
std::string | getErrorString () const |
Gets error description. More... | |
void | setCredentials (const std::string &login, const std::string &password) |
Sets credentials for HTTP authentication. More... | |
void | getCredentials (std::string &login, std::string &password) |
Gets credential for HTTP authentication. More... | |
void | enableBasicHttpAuthentication (bool enable) |
Enables or disables basic HTTP authentication. More... | |
bool | basicHttpAuthenticationEnabled () |
Checks if basic HTTP authentication is enabled. More... | |
void | enableDigestHttpAuthentication (bool enable) |
Enables or disables digest HTTP authentication. More... | |
bool | digestHttpAuthenticationEnabled () |
Checks if digest HTTP authentication is enabled. More... | |
Static Public Member Functions | |
static std::string | responseCodeDescription (long code) |
HttpMessage class. Represents Http request that can be executed using HttpSession object.
typedef std::vector<std::pair<std::string, std::string> > OpenAB::HttpMessage::Headers |
OpenAB::HttpMessage::HttpMessage | ( | ) |
Constructor.
OpenAB::HttpMessage::~HttpMessage | ( | ) |
Destructor, virtual by default.
void OpenAB::HttpMessage::appendHeader | ( | const std::string & | key, |
const std::string & | value | ||
) |
Appends given header to message headers.
[in] | key | of header. |
[in] | value | of header. |
bool OpenAB::HttpMessage::basicHttpAuthenticationEnabled | ( | ) |
Checks if basic HTTP authentication is enabled.
bool OpenAB::HttpMessage::digestHttpAuthenticationEnabled | ( | ) |
Checks if digest HTTP authentication is enabled.
void OpenAB::HttpMessage::enableBasicHttpAuthentication | ( | bool | enable | ) |
Enables or disables basic HTTP authentication.
[in] | enable | enable or disable authentication |
void OpenAB::HttpMessage::enableDigestHttpAuthentication | ( | bool | enable | ) |
Enables or disables digest HTTP authentication.
[in] | enable | enable or disable authentication |
bool OpenAB::HttpMessage::followRedirection | ( | ) | const |
Returns status of redirections.
void OpenAB::HttpMessage::getCredentials | ( | std::string & | login, |
std::string & | password | ||
) |
Gets credential for HTTP authentication.
[out] | login | login to be used for authentication |
[out] | password | password to be used for authentication |
std::string OpenAB::HttpMessage::getCustomRequestType | ( | ) | const |
Returns custom request type, if request type is set to RequestType::CUSTOM.
std::string OpenAB::HttpMessage::getData | ( | ) | const |
Returns currently set body of message.
std::string OpenAB::HttpMessage::getErrorString | ( | ) | const |
Gets error description.
const HttpMessage::Headers & OpenAB::HttpMessage::getHeaders | ( | ) | const |
Returns all headers set for message.
HttpMessage::RequestType OpenAB::HttpMessage::getRequestType | ( | ) | const |
Returns currently set request type.
std::string OpenAB::HttpMessage::getResponse | ( | ) | const |
Gets request response.
long OpenAB::HttpMessage::getResponseCode | ( | ) | const |
Gets request response code.
HttpMessage::Headers OpenAB::HttpMessage::getResponseHeaders | ( | ) | const |
Gets response headers.
std::string OpenAB::HttpMessage::getURL | ( | ) | const |
Returns currently set URL.
currently | set URL. |
|
static |
void OpenAB::HttpMessage::setCredentials | ( | const std::string & | login, |
const std::string & | password | ||
) |
Sets credentials for HTTP authentication.
[in] | login | login to be used for authentication |
[in] | password | password to be used for authentication |
void OpenAB::HttpMessage::setData | ( | const std::string & | data | ) |
void OpenAB::HttpMessage::setErrorString | ( | const std::string & | errorStr | ) |
Sets error description.
[in] | errorStr | error description |
void OpenAB::HttpMessage::setFollowRedirection | ( | bool | follow | ) |
Should redirections be followed.
follow | true if redirections should be followed. |
void OpenAB::HttpMessage::setRequestType | ( | HttpMessage::RequestType | type | ) |
Sets message request type.
[in] | type | request type to be set. |
void OpenAB::HttpMessage::setRequestType | ( | const std::string & | custom | ) |
Sets custom message request type. Automatically sets request type to RequestType::CUSTOM.
[in] | custom | custom request type. |
void OpenAB::HttpMessage::setResponse | ( | const std::string & | response | ) |
Sets response data.
[in] | response | request response. |
void OpenAB::HttpMessage::setResponseCode | ( | long | code | ) |
Sets request response code.
[in] | code | response code. |
void OpenAB::HttpMessage::setResponseHeaders | ( | const std::string & | headers | ) |
Sets response headers data.
[in] | headers | response headers. |
void OpenAB::HttpMessage::setURL | ( | const std::string & | url | ) |
Sets URL of message.
[in] | url | URL. |