NUGU SDK Linux  1.7.6
NuguClientKit::NuguHttpRest Class Reference

NUGU HTTP Rest. More...

#include <nugu_http_rest.hh>

Public Types

typedef std::function< void(const NuguHttpResponse *resp)> ResponseCallback
 Callback prototype for receiving async response.
 

Public Member Functions

bool addHeader (const std::string &key, const std::string &value)
 Add a key-value string to common header. More...
 
bool del (const std::string &path, const NuguHttpHeader *additional_header, ResponseCallback cb)
 HTTP DELETE async requests. More...
 
NuguHttpResponsedel (const std::string &path, const NuguHttpHeader *additional_header=nullptr)
 HTTP DELETE requests. More...
 
bool del (const std::string &path, ResponseCallback cb)
 HTTP DELETE async requests. More...
 
std::string findHeader (const std::string &key)
 Find a value for key from common header. More...
 
bool get (const std::string &path, const NuguHttpHeader *additional_header, ResponseCallback cb)
 HTTP GET async requests. More...
 
NuguHttpResponseget (const std::string &path, const NuguHttpHeader *additional_header=nullptr)
 HTTP GET requests. More...
 
bool get (const std::string &path, ResponseCallback cb)
 HTTP GET async requests. More...
 
std::string getUrl ()
 Get the url of host. More...
 
 NuguHttpRest (const std::string &url)
 
bool post (const std::string &path, const std::string &body, const NuguHttpHeader *additional_header, ResponseCallback cb)
 HTTP POST async requests. More...
 
NuguHttpResponsepost (const std::string &path, const std::string &body, const NuguHttpHeader *additional_header=nullptr)
 HTTP POST requests. More...
 
bool post (const std::string &path, const std::string &body, ResponseCallback cb)
 HTTP POST async requests. More...
 
bool put (const std::string &path, const std::string &body, const NuguHttpHeader *additional_header, ResponseCallback cb)
 HTTP PUT async requests. More...
 
NuguHttpResponseput (const std::string &path, const std::string &body, const NuguHttpHeader *additional_header=nullptr)
 HTTP PUT requests. More...
 
bool put (const std::string &path, const std::string &body, ResponseCallback cb)
 HTTP PUT async requests. More...
 
bool removeHeader (const std::string &key)
 Remove a key-value from common header. More...
 
void setConnectionTimeout (long msecs)
 Set connection timeout to host. More...
 
void setTimeout (long msecs)
 Set timeout to host. More...
 

Detailed Description

NUGU HTTP Rest.

Member Function Documentation

◆ setTimeout()

void NuguClientKit::NuguHttpRest::setTimeout ( long  msecs)

Set timeout to host.

Parameters
[in]msecsmillisecond

◆ setConnectionTimeout()

void NuguClientKit::NuguHttpRest::setConnectionTimeout ( long  msecs)

Set connection timeout to host.

Parameters
[in]msecsmillisecond

◆ getUrl()

std::string NuguClientKit::NuguHttpRest::getUrl ( )

Get the url of host.

Returns
url

◆ addHeader()

bool NuguClientKit::NuguHttpRest::addHeader ( const std::string &  key,
const std::string &  value 
)

Add a key-value string to common header.

Parameters
[in]keykey string, e.g. "Content-Type"
[in]valuevalue string, e.g. "application/json"
Returns
result
Return values
truesuccess
falsefailure

◆ removeHeader()

bool NuguClientKit::NuguHttpRest::removeHeader ( const std::string &  key)

Remove a key-value from common header.

Parameters
[in]keykey string, e.g. "Content-Type"
Returns
result
Return values
truesuccess
falsefailure

◆ findHeader()

std::string NuguClientKit::NuguHttpRest::findHeader ( const std::string &  key)

Find a value for key from common header.

Parameters
[in]keykey string, e.g. "Content-Type"
Returns
value

◆ get() [1/3]

NuguHttpResponse* NuguClientKit::NuguHttpRest::get ( const std::string &  path,
const NuguHttpHeader additional_header = nullptr 
)

HTTP GET requests.

Parameters
[in]pathurl path
[in]additional_headeradditional header
Returns
HTTP response object
See also
nugu_http_response_free()

◆ get() [2/3]

bool NuguClientKit::NuguHttpRest::get ( const std::string &  path,
ResponseCallback  cb 
)

HTTP GET async requests.

Parameters
[in]pathurl path
[in]cbcallback function to receive response
Returns
result
Return values
truesuccess
falsefailure

◆ get() [3/3]

bool NuguClientKit::NuguHttpRest::get ( const std::string &  path,
const NuguHttpHeader additional_header,
ResponseCallback  cb 
)

HTTP GET async requests.

Parameters
[in]pathurl path
[in]additional_headeradditional header
[in]cbcallback function to receive response
Returns
result
Return values
truesuccess
falsefailure

◆ post() [1/3]

NuguHttpResponse* NuguClientKit::NuguHttpRest::post ( const std::string &  path,
const std::string &  body,
const NuguHttpHeader additional_header = nullptr 
)

HTTP POST requests.

Parameters
[in]pathurl path
[in]bodybody data to send
[in]additional_headeradditional header
Returns
HTTP response object
See also
nugu_http_response_free()

◆ post() [2/3]

bool NuguClientKit::NuguHttpRest::post ( const std::string &  path,
const std::string &  body,
ResponseCallback  cb 
)

HTTP POST async requests.

Parameters
[in]pathurl path
[in]bodybody data to send
[in]cbcallback function to receive response
Returns
result
Return values
truesuccess
falsefailure

◆ post() [3/3]

bool NuguClientKit::NuguHttpRest::post ( const std::string &  path,
const std::string &  body,
const NuguHttpHeader additional_header,
ResponseCallback  cb 
)

HTTP POST async requests.

Parameters
[in]pathurl path
[in]bodybody data to send
[in]additional_headeradditional header
[in]cbcallback function to receive response
Returns
result
Return values
truesuccess
falsefailure

◆ put() [1/3]

NuguHttpResponse* NuguClientKit::NuguHttpRest::put ( const std::string &  path,
const std::string &  body,
const NuguHttpHeader additional_header = nullptr 
)

HTTP PUT requests.

Parameters
[in]pathurl path
[in]bodybody data to send
[in]additional_headeradditional header
Returns
HTTP response object
See also
nugu_http_response_free()

◆ put() [2/3]

bool NuguClientKit::NuguHttpRest::put ( const std::string &  path,
const std::string &  body,
ResponseCallback  cb 
)

HTTP PUT async requests.

Parameters
[in]pathurl path
[in]bodybody data to send
[in]cbcallback function to receive response
Returns
result
Return values
truesuccess
falsefailure

◆ put() [3/3]

bool NuguClientKit::NuguHttpRest::put ( const std::string &  path,
const std::string &  body,
const NuguHttpHeader additional_header,
ResponseCallback  cb 
)

HTTP PUT async requests.

Parameters
[in]pathurl path
[in]bodybody data to send
[in]additional_headeradditional header
[in]cbcallback function to receive response
Returns
result
Return values
truesuccess
falsefailure

◆ del() [1/3]

NuguHttpResponse* NuguClientKit::NuguHttpRest::del ( const std::string &  path,
const NuguHttpHeader additional_header = nullptr 
)

HTTP DELETE requests.

Parameters
[in]pathurl path
[in]additional_headeradditional header
Returns
HTTP response object
See also
nugu_http_response_free()

◆ del() [2/3]

bool NuguClientKit::NuguHttpRest::del ( const std::string &  path,
ResponseCallback  cb 
)

HTTP DELETE async requests.

Parameters
[in]pathurl path
[in]cbcallback function to receive response
Returns
result
Return values
truesuccess
falsefailure

◆ del() [3/3]

bool NuguClientKit::NuguHttpRest::del ( const std::string &  path,
const NuguHttpHeader additional_header,
ResponseCallback  cb 
)

HTTP DELETE async requests.

Parameters
[in]pathurl path
[in]additional_headeradditional header
[in]cbcallback function to receive response
Returns
result
Return values
truesuccess
falsefailure

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