noos::cloud::http_response Class Reference

class for taking the body of the streambuf , in other case it will return an error More...

#include <http_response.hpp>

Public Member Functions

 http_response (std::function< void(error_code error)> callback)
 construct a response object by setting the error receiver callback More...
 
 http_response (std::string arg)
 constructor only for unit testing
 
unsigned int content_length ()
 get the content length streambuf response More...
 
unsigned int strip_http_header (unsigned int bytes)
 remove/strip the HTTP header and More...
 
std::string to_string ()
 conversion from streambuf to string
 
unsigned int bytes_received () const
 total POST data bytes received
 
bool check_http_header ()
 check if HTTP status is 200 More...
 
bool consume_buffer (std::function< void(std::string)> callback, unsigned int bytes)
 take data from the response and save it in JSON
 
void flush_data ()
 clean the variables
 

Detailed Description

class for taking the body of the streambuf , in other case it will return an error

Version
0.7.0
Date
12 August 2016
Note
The defined error callback may receive the following errors:
  • boost::system::errc::bad_message if the header is not followed by a double return carriage
  • boost::system::errc::no_message if the platform does not respond with any data
  • boost::system::errc::protocol_not_supported if the reply does not conform to HTTP 1.1
  • boost::system::errc::protocol_error if HTTP header does not respond with 200 status code
Inheritance diagram for noos::cloud::http_response:

Constructor & Destructor Documentation

noos::cloud::http_response::http_response ( std::function< void(error_code error)>  callback)

construct a response object by setting the error receiver callback

Parameters
callbackwill receive errors

Member Function Documentation

unsigned int noos::cloud::http_response::content_length ( )

get the content length streambuf response

Returns
content-length or -1 for not found
unsigned int noos::cloud::http_response::strip_http_header ( unsigned int  bytes)

remove/strip the HTTP header and

Returns
the body
bool noos::cloud::http_response::check_http_header ( )

check if HTTP status is 200

Parameters
errorhandler will receive error if response is invalid

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