Public Types | Public Member Functions | Protected Member Functions | Friends

atscppapi::AsyncHttpFetch Class Reference

This class provides an implementation of AsyncProvider that makes HTTP requests asynchronously. More...

#include <AsyncHttpFetch.h>

Inherits atscppapi::AsyncProvider.

Collaboration diagram for atscppapi::AsyncHttpFetch:
Collaboration graph
[legend]

Public Types

enum  Result { RESULT_SUCCESS = 10000, RESULT_TIMEOUT, RESULT_FAILURE }

Public Member Functions

 AsyncHttpFetch (const std::string &url_str, HttpMethod http_method=HTTP_METHOD_GET)
 AsyncHttpFetch (const std::string &url_str, const std::string &request_body)
Headers & getRequestHeaders ()
 Used to manipulate the headers of the request to be made.
Result getResult () const
 Used to extract the response after request completion.
const Url & getRequestUrl () const
const std::string & getRequestBody () const
const Response & getResponse () const
 Used to extract the response after request completion.
void getResponseBody (const void *&body, size_t &body_size) const
 Used to extract the body of the response after request completion.
virtual void run ()
 Starts a HTTP fetch of the Request contained.

Protected Member Functions

virtual ~AsyncHttpFetch ()

Friends

class utils::internal

Detailed Description

This class provides an implementation of AsyncProvider that makes HTTP requests asynchronously.

This provider automatically self-destructs after the completion of the request.

See example async_http_fetch for sample usage.

Definition at line 46 of file AsyncHttpFetch.h.


Member Enumeration Documentation

Enumerator:
RESULT_SUCCESS 
RESULT_TIMEOUT 
RESULT_FAILURE 

Definition at line 59 of file AsyncHttpFetch.h.


Constructor & Destructor Documentation

atscppapi::AsyncHttpFetch::AsyncHttpFetch ( const std::string &  url_str,
HttpMethod  http_method = HTTP_METHOD_GET 
)
atscppapi::AsyncHttpFetch::AsyncHttpFetch ( const std::string &  url_str,
const std::string &  request_body 
)
virtual atscppapi::AsyncHttpFetch::~AsyncHttpFetch (  )  [protected, virtual]

Member Function Documentation

const std::string& atscppapi::AsyncHttpFetch::getRequestBody (  )  const
Returns:
Non-mutable reference to the request body.
Headers& atscppapi::AsyncHttpFetch::getRequestHeaders (  ) 

Used to manipulate the headers of the request to be made.

Returns:
A reference to mutable headers.
const Url& atscppapi::AsyncHttpFetch::getRequestUrl (  )  const
Returns:
Non-mutable reference to the request URL.
const Response& atscppapi::AsyncHttpFetch::getResponse (  )  const

Used to extract the response after request completion.

Returns:
Non-mutable reference to the response.
void atscppapi::AsyncHttpFetch::getResponseBody ( const void *&  body,
size_t &  body_size 
) const

Used to extract the body of the response after request completion.

On unsuccessful completion, values (NULL, 0) are set.

Parameters:
body Output argument; will point to the body
body_size Output argument; will contain the size of the body
Result atscppapi::AsyncHttpFetch::getResult (  )  const

Used to extract the response after request completion.

Returns:
Result of the operation
virtual void atscppapi::AsyncHttpFetch::run (  )  [virtual]

Starts a HTTP fetch of the Request contained.

Implements atscppapi::AsyncProvider.


Friends And Related Function Documentation

friend class utils::internal [friend]

Definition at line 105 of file AsyncHttpFetch.h.


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