RAPP Platform API
 All Classes Namespaces Files Functions Variables Typedefs
rapp::cloud::asio_handler Class Reference

base class for asio handling, including helper methods and most protected members More...

#include <asio_handler.hpp>

Inheritance diagram for rapp::cloud::asio_handler:

Public Member Functions

 asio_handler (const std::string token)
 ctor More...
 
void content_length (std::string response, std::size_t &length)
 get the content leangth from More...
 
std::string decode64 (const std::string &val)
 decode base64 More...
 
std::string encode64 (const std::string &val)
 encode base64 More...
 
void error_handler (const boost::system::error_code &error)
 Handle an Error. More...
 
std::string escape_string (const std::string &str)
 escape JSON strings when sending them over the socket More...
 
bool has_content_length (std::string response)
 examine if the header response contains a content-length filed More...
 
void invalid_request (const std::string message)
 Handle Invalid Query - e.g.: response which states our query was invalid. More...
 
std::string random_boundary () const
 Create a random boundary for the multipart/form in HTTP. More...
 
std::string strip_header (std::string response)
 remove/strip the HTTP header and More...
 

Protected Attributes

std::size_t bytes_transferred_ = 0
 Bytes Transferred. More...
 
std::function< void(std::string)> callback_
 Callback Handler - use with std::bind or boost variant. More...
 
std::size_t content_length_ = 0
 Content-Length. More...
 
std::atomic< bool > flag_ = {false}
 flag used to extract header More...
 
std::string header_
 Header that will be used. More...
 
std::string json_
 JSON reply. More...
 
std::string post_
 Actual post Data. More...
 
boost::asio::streambuf request_
 Request Container. More...
 
boost::asio::streambuf response_
 Response Container. More...
 
std::unique_ptr
< boost::asio::deadline_timer > 
timer_
 time-out timer More...
 
const std::string token_
 user authentication token More...
 

Detailed Description

base class for asio handling, including helper methods and most protected members

Version
0.6.0
Date
April 2016
Author
Alex Giokas a.gki.nosp@m.okas.nosp@m.@orte.nosp@m.lio..nosp@m.co.uk

Definition at line 14 of file asio_handler.hpp.

Constructor & Destructor Documentation

rapp::cloud::asio_handler::asio_handler ( const std::string  token)

ctor

Definition at line 19 of file asio_handler.hpp.

Member Function Documentation

void rapp::cloud::asio_handler::content_length ( std::string  response,
std::size_t &  length 
)

get the content leangth from

Parameters
header

Definition at line 16 of file asio_handler.cpp.

std::string rapp::cloud::asio_handler::decode64 ( const std::string &  val)

decode base64

Parameters
valmust be encoded using base64

Definition at line 101 of file asio_handler.cpp.

std::string rapp::cloud::asio_handler::encode64 ( const std::string &  val)

encode base64

Parameters
valmust be plain-text string
Returns
a base64 encoded string

Definition at line 110 of file asio_handler.cpp.

void rapp::cloud::asio_handler::error_handler ( const boost::system::error_code &  error)

Handle an Error.

Parameters
erroris the raised error from the client

Definition at line 6 of file asio_handler.cpp.

std::string rapp::cloud::asio_handler::escape_string ( const std::string &  str)

escape JSON strings when sending them over the socket

Parameters
strwill be escaped and returned

Definition at line 82 of file asio_handler.cpp.

bool rapp::cloud::asio_handler::has_content_length ( std::string  response)

examine if the header response contains a content-length filed

Definition at line 42 of file asio_handler.cpp.

void rapp::cloud::asio_handler::invalid_request ( const std::string  message)

Handle Invalid Query - e.g.: response which states our query was invalid.

Definition at line 11 of file asio_handler.cpp.

std::string rapp::cloud::asio_handler::random_boundary ( ) const

Create a random boundary for the multipart/form in HTTP.

Definition at line 67 of file asio_handler.cpp.

std::string rapp::cloud::asio_handler::strip_header ( std::string  response)

remove/strip the HTTP header and

Returns
the body

Definition at line 55 of file asio_handler.cpp.

Member Data Documentation

std::size_t rapp::cloud::asio_handler::bytes_transferred_ = 0
protected

Bytes Transferred.

Definition at line 74 of file asio_handler.hpp.

std::function<void(std::string)> rapp::cloud::asio_handler::callback_
protected

Callback Handler - use with std::bind or boost variant.

Definition at line 61 of file asio_handler.hpp.

std::size_t rapp::cloud::asio_handler::content_length_ = 0
protected

Content-Length.

Definition at line 72 of file asio_handler.hpp.

std::atomic<bool> rapp::cloud::asio_handler::flag_ = {false}
protected

flag used to extract header

Definition at line 70 of file asio_handler.hpp.

std::string rapp::cloud::asio_handler::header_
protected

Header that will be used.

Definition at line 57 of file asio_handler.hpp.

std::string rapp::cloud::asio_handler::json_
protected

JSON reply.

Definition at line 76 of file asio_handler.hpp.

std::string rapp::cloud::asio_handler::post_
protected

Actual post Data.

Definition at line 59 of file asio_handler.hpp.

boost::asio::streambuf rapp::cloud::asio_handler::request_
protected

Request Container.

Definition at line 63 of file asio_handler.hpp.

boost::asio::streambuf rapp::cloud::asio_handler::response_
protected

Response Container.

Definition at line 65 of file asio_handler.hpp.

std::unique_ptr<boost::asio::deadline_timer> rapp::cloud::asio_handler::timer_
protected

time-out timer

Definition at line 68 of file asio_handler.hpp.

const std::string rapp::cloud::asio_handler::token_
protected

user authentication token

Definition at line 78 of file asio_handler.hpp.


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