C++ Rest SDK
The C++ REST SDK is a Microsoft project for cloud-based client-server communication in native code using a modern asynchronous C++ API design. This project aims to help C++ developers connect to and interact with services.
Public Member Functions | Protected Attributes | Friends | List of all members
web::http::details::http_msg_base Class Reference

Base class for HTTP messages. This class is to store common functionality so it isn't duplicated on both the request and response side. More...

#include <http_msg.h>

Inheritance diagram for web::http::details::http_msg_base:
web::http::details::_http_request web::http::details::_http_response

Public Member Functions

http_headersheaders ()
 
_ASYNCRTIMP void set_body (const concurrency::streams::istream &instream, const utf8string &contentType)
 
_ASYNCRTIMP void set_body (const concurrency::streams::istream &instream, const utf16string &contentType)
 
_ASYNCRTIMP void set_body (const concurrency::streams::istream &instream, utility::size64_t contentLength, const utf8string &contentType)
 
_ASYNCRTIMP void set_body (const concurrency::streams::istream &instream, utility::size64_t contentLength, const utf16string &contentType)
 
utility::string_t parse_and_check_content_type (bool ignore_content_type, const std::function< bool(const utility::string_t &)> &check_content_type)
 Helper function for extract functions. Parses the Content-Type header and check to make sure it matches, throws an exception if not. More...
 
_ASYNCRTIMP utf8string extract_utf8string (bool ignore_content_type=false)
 
_ASYNCRTIMP utf16string extract_utf16string (bool ignore_content_type=false)
 
_ASYNCRTIMP utility::string_t extract_string (bool ignore_content_type=false)
 
_ASYNCRTIMP json::value _extract_json (bool ignore_content_type=false)
 
_ASYNCRTIMP std::vector< unsigned char > _extract_vector ()
 
virtual _ASYNCRTIMP utility::string_t to_string () const
 
virtual _ASYNCRTIMP void _complete (utility::size64_t bodySize, const std::exception_ptr &exceptionPtr=std::exception_ptr())
 Completes this message More...
 
void set_instream (const concurrency::streams::istream &instream)
 Set the stream through which the message body could be read More...
 
const concurrency::streams::istream & instream () const
 Get the stream through which the message body could be read More...
 
void set_outstream (const concurrency::streams::ostream &outstream, bool is_default)
 Set the stream through which the message body could be written More...
 
const concurrency::streams::ostream & outstream () const
 Get the stream through which the message body could be written More...
 
const pplx::task_completion_event< utility::size64_t > & _get_data_available () const
 
_ASYNCRTIMP void _prepare_to_receive_data ()
 Prepare the message with an output stream to receive network data More...
 
_ASYNCRTIMP size_t _get_content_length ()
 Determine the content length More...
 

Protected Attributes

concurrency::streams::istream m_inStream
 Stream to read the message body. By default this is an invalid stream. The user could set the instream on a request by calling set_request_stream(...). This would also be set when set_body() is called - a stream from the body is constructed and set. Even in the presense of msg body this stream could be invalid. An example would be when the user sets an ostream for the response. With that API the user does not provide the ability to read the msg body. Thus m_instream is valid when there is a msg body and it can actually be read More...
 
concurrency::streams::ostream m_outStream
 stream to write the msg body By default this is an invalid stream. The user could set this on the response (for http_client). In all the other cases we would construct one to transfer the data from the network into the message body. More...
 
http_headers m_headers
 
bool m_default_outstream
 
pplx::task_completion_event< utility::size64_t > m_data_available
 The TCE is used to signal the availability of the message body. More...
 

Friends

class http::client::http_client
 

Detailed Description

Base class for HTTP messages. This class is to store common functionality so it isn't duplicated on both the request and response side.

Member Function Documentation

virtual _ASYNCRTIMP void web::http::details::http_msg_base::_complete ( utility::size64_t  bodySize,
const std::exception_ptr &  exceptionPtr = std::exception_ptr() 
)
virtual

Completes this message

_ASYNCRTIMP size_t web::http::details::http_msg_base::_get_content_length ( )

Determine the content length

Returns
size_t::max if there is content with unknown length (transfer_encoding:chunked) 0 if there is no content length if there is content with known length

This routine should only be called after a msg (request/response) has been completely constructed.

_ASYNCRTIMP void web::http::details::http_msg_base::_prepare_to_receive_data ( )

Prepare the message with an output stream to receive network data

const concurrency::streams::istream& web::http::details::http_msg_base::instream ( ) const
inline

Get the stream through which the message body could be read

const concurrency::streams::ostream& web::http::details::http_msg_base::outstream ( ) const
inline

Get the stream through which the message body could be written

utility::string_t web::http::details::http_msg_base::parse_and_check_content_type ( bool  ignore_content_type,
const std::function< bool(const utility::string_t &)> &  check_content_type 
)

Helper function for extract functions. Parses the Content-Type header and check to make sure it matches, throws an exception if not.

Parameters
ignore_content_typeIf true ignores the Content-Type header value.
check_content_typeFunction to verify additional information on Content-Type.
Returns
A string containing the charset, an empty string if no Content-Type header is empty.
void web::http::details::http_msg_base::set_instream ( const concurrency::streams::istream &  instream)
inline

Set the stream through which the message body could be read

void web::http::details::http_msg_base::set_outstream ( const concurrency::streams::ostream &  outstream,
bool  is_default 
)
inline

Set the stream through which the message body could be written

Member Data Documentation

pplx::task_completion_event<utility::size64_t> web::http::details::http_msg_base::m_data_available
protected

The TCE is used to signal the availability of the message body.

concurrency::streams::istream web::http::details::http_msg_base::m_inStream
protected

Stream to read the message body. By default this is an invalid stream. The user could set the instream on a request by calling set_request_stream(...). This would also be set when set_body() is called - a stream from the body is constructed and set. Even in the presense of msg body this stream could be invalid. An example would be when the user sets an ostream for the response. With that API the user does not provide the ability to read the msg body. Thus m_instream is valid when there is a msg body and it can actually be read

concurrency::streams::ostream web::http::details::http_msg_base::m_outStream
protected

stream to write the msg body By default this is an invalid stream. The user could set this on the response (for http_client). In all the other cases we would construct one to transfer the data from the network into the message body.


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