OpenAB  1.0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
OpenAB::HttpMessage Class Reference

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 HeadersgetHeaders () 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)
 

Detailed Description

HttpMessage class. Represents Http request that can be executed using HttpSession object.

Member Typedef Documentation

typedef std::vector<std::pair<std::string, std::string> > OpenAB::HttpMessage::Headers

Member Enumeration Documentation

Enumerator
POST 
GET 
PUT 
CUSTOM 
Enumerator
OK 
CREATED 
ACCEPTED 
NO_CONTENT 
MULTISTATUS 
MOVED_PERMAMENTLY 
BAD_REQUEST 
UNAUTHORIZED 
FORBIDDEN 
NOT_FOUND 
PRECONDITION_FAILED 

Constructor & Destructor Documentation

OpenAB::HttpMessage::HttpMessage ( )

Constructor.

OpenAB::HttpMessage::~HttpMessage ( )

Destructor, virtual by default.

Member Function Documentation

void OpenAB::HttpMessage::appendHeader ( const std::string &  key,
const std::string &  value 
)

Appends given header to message headers.

Parameters
[in]keyof header.
[in]valueof header.
bool OpenAB::HttpMessage::basicHttpAuthenticationEnabled ( )

Checks if basic HTTP authentication is enabled.

Returns
true if basic HTTP authentication is enabled, false otherwise.
bool OpenAB::HttpMessage::digestHttpAuthenticationEnabled ( )

Checks if digest HTTP authentication is enabled.

Returns
true if digest HTTP authentication is enabled, false otherwise.
void OpenAB::HttpMessage::enableBasicHttpAuthentication ( bool  enable)

Enables or disables basic HTTP authentication.

Note
authentication credentials can be set using setCredentials.
Parameters
[in]enableenable or disable authentication
void OpenAB::HttpMessage::enableDigestHttpAuthentication ( bool  enable)

Enables or disables digest HTTP authentication.

Note
authentication credentials can be set using setCredentials.
Parameters
[in]enableenable or disable authentication
bool OpenAB::HttpMessage::followRedirection ( ) const

Returns status of redirections.

Returns
true if redirection will be followed.
void OpenAB::HttpMessage::getCredentials ( std::string &  login,
std::string &  password 
)

Gets credential for HTTP authentication.

Parameters
[out]loginlogin to be used for authentication
[out]passwordpassword to be used for authentication
std::string OpenAB::HttpMessage::getCustomRequestType ( ) const

Returns custom request type, if request type is set to RequestType::CUSTOM.

Returns
custom request type or empty string.
std::string OpenAB::HttpMessage::getData ( ) const

Returns currently set body of message.

Returns
currently set body of message.
std::string OpenAB::HttpMessage::getErrorString ( ) const

Gets error description.

Returns
Error description or empty string if description was not set.
const HttpMessage::Headers & OpenAB::HttpMessage::getHeaders ( ) const

Returns all headers set for message.

HttpMessage::RequestType OpenAB::HttpMessage::getRequestType ( ) const

Returns currently set request type.

Returns
currently set request type.
std::string OpenAB::HttpMessage::getResponse ( ) const

Gets request response.

Returns
request response.
long OpenAB::HttpMessage::getResponseCode ( ) const

Gets request response code.

Returns
request response code
HttpMessage::Headers OpenAB::HttpMessage::getResponseHeaders ( ) const

Gets response headers.

Returns
response headers.
std::string OpenAB::HttpMessage::getURL ( ) const

Returns currently set URL.

Parameters
currentlyset URL.
std::string OpenAB::HttpMessage::responseCodeDescription ( long  code)
static
void OpenAB::HttpMessage::setCredentials ( const std::string &  login,
const std::string &  password 
)

Sets credentials for HTTP authentication.

Parameters
[in]loginlogin to be used for authentication
[in]passwordpassword to be used for authentication
void OpenAB::HttpMessage::setData ( const std::string &  data)

Sets body of message.

Parameters
[in]databody of message.
Todo:
add support for non text data
void OpenAB::HttpMessage::setErrorString ( const std::string &  errorStr)

Sets error description.

Parameters
[in]errorStrerror description
void OpenAB::HttpMessage::setFollowRedirection ( bool  follow)

Should redirections be followed.

Parameters
followtrue if redirections should be followed.
void OpenAB::HttpMessage::setRequestType ( HttpMessage::RequestType  type)

Sets message request type.

Parameters
[in]typerequest type to be set.
Note
This version of setRequestType does not accept RequestType::CUSTOM.
void OpenAB::HttpMessage::setRequestType ( const std::string &  custom)

Sets custom message request type. Automatically sets request type to RequestType::CUSTOM.

Parameters
[in]customcustom request type.
void OpenAB::HttpMessage::setResponse ( const std::string &  response)

Sets response data.

Parameters
[in]responserequest response.
Todo:
add support for non textual responses.
void OpenAB::HttpMessage::setResponseCode ( long  code)

Sets request response code.

Parameters
[in]coderesponse code.
void OpenAB::HttpMessage::setResponseHeaders ( const std::string &  headers)

Sets response headers data.

Parameters
[in]headersresponse headers.
void OpenAB::HttpMessage::setURL ( const std::string &  url)

Sets URL of message.

Parameters
[in]urlURL.

The documentation for this class was generated from the following files: