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

base class for asynchronous http websockets used for connecting to cloud services More...

#include <asio_service_http.hpp>

Inheritance diagram for rapp::cloud::asio_service_http:
Collaboration diagram for rapp::cloud::asio_service_http:

Public Member Functions

 asio_service_http (const std::string token)
 
void schedule (boost::asio::ip::tcp::resolver::query &query, boost::asio::ip::tcp::resolver &resolver, boost::asio::io_service &io_service)
 

Protected Member Functions

void check_timeout ()
 check timed-out More...
 
void handle_connect (const boost::system::error_code &err, boost::asio::ip::tcp::resolver::iterator endpoint_iterator)
 
void handle_read_content (const boost::system::error_code &err, std::size_t bytes)
 Callback for Handling Actual Data Contents. More...
 
void handle_read_headers (const boost::system::error_code &err)
 Callback for Handling Headers. More...
 
void handle_read_status_line (const boost::system::error_code &err)
 Callback for handling HTTP Header Response Data. More...
 
void handle_resolve (const boost::system::error_code &err, boost::asio::ip::tcp::resolver::iterator endpoint_iterator)
 Callback for Handling Address Resolution. More...
 
void handle_write_request (const boost::system::error_code &err)
 Callback for handling request and waiting for response. More...
 
void reset ()
 reset handler (clear data, bytes, etc) and stop connection More...
 
- Protected Member Functions inherited from rapp::cloud::asio_handler
 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...
 

Private Attributes

std::unique_ptr
< boost::asio::ip::tcp::socket > 
socket_
 TCP Socket (plain-text) More...
 

Additional Inherited Members

- Protected Attributes inherited from rapp::cloud::asio_handler
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 asynchronous http websockets used for connecting to cloud services

Version
0.6.0
Date
May 2016
Author
Alex Gkiokas a.gki.nosp@m.okas.nosp@m.@orte.nosp@m.lio..nosp@m.co.uk TODO: rename to asio_socket_http

Definition at line 14 of file asio_service_http.hpp.

Constructor & Destructor Documentation

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

Construct the asio http service

Parameters
tokenis the rapp.cloud authentication token

Definition at line 21 of file asio_service_http.hpp.

Member Function Documentation

void rapp::cloud::asio_service_http::check_timeout ( )
protected

check timed-out

Definition at line 230 of file asio_service_http.cpp.

void rapp::cloud::asio_service_http::handle_connect ( const boost::system::error_code &  err,
boost::asio::ip::tcp::resolver::iterator  endpoint_iterator 
)
protected

Callback for Handling Connection Events

Parameters
erris a possible error
endpoint_iteratoris boosts' hostname address handler

Definition at line 59 of file asio_service_http.cpp.

void rapp::cloud::asio_service_http::handle_read_content ( const boost::system::error_code &  err,
std::size_t  bytes 
)
protected

Callback for Handling Actual Data Contents.

Parameters
erris a possible error message

Definition at line 163 of file asio_service_http.cpp.

void rapp::cloud::asio_service_http::handle_read_headers ( const boost::system::error_code &  err)
protected

Callback for Handling Headers.

Parameters
erris a possible error message

Definition at line 143 of file asio_service_http.cpp.

void rapp::cloud::asio_service_http::handle_read_status_line ( const boost::system::error_code &  err)
protected

Callback for handling HTTP Header Response Data.

Parameters
erris a possible error message

Definition at line 107 of file asio_service_http.cpp.

void rapp::cloud::asio_service_http::handle_resolve ( const boost::system::error_code &  err,
boost::asio::ip::tcp::resolver::iterator  endpoint_iterator 
)
protected

Callback for Handling Address Resolution.

Parameters
erris a possible error
endpoint_iteratoris boost's hostname address handler

Definition at line 41 of file asio_service_http.cpp.

void rapp::cloud::asio_service_http::handle_write_request ( const boost::system::error_code &  err)
protected

Callback for handling request and waiting for response.

Parameters
erris a possible error

Definition at line 88 of file asio_service_http.cpp.

void rapp::cloud::asio_service_http::reset ( )
protected

reset handler (clear data, bytes, etc) and stop connection

Definition at line 217 of file asio_service_http.cpp.

void rapp::cloud::asio_service_http::schedule ( boost::asio::ip::tcp::resolver::query &  query,
boost::asio::ip::tcp::resolver &  resolver,
boost::asio::io_service &  io_service 
)
virtual

schedule this client as a job for execution using

Parameters
querydefines the actual URL/URI
resolveris the URL/URI resolver reference
io_serviceis the queue on which jobs are scheduled

Implements rapp::cloud::asio_socket.

Definition at line 6 of file asio_service_http.cpp.

Member Data Documentation

std::unique_ptr<boost::asio::ip::tcp::socket> rapp::cloud::asio_service_http::socket_
private

TCP Socket (plain-text)

Definition at line 78 of file asio_service_http.hpp.


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