libtasks Documentation  1.6
tasks::net::http_base Class Referenceabstract

#include <http_base.h>

Inheritance diagram for tasks::net::http_base:
Collaboration diagram for tasks::net::http_base:

Public Member Functions

 http_base ()
 
virtual ~http_base ()
 
void set_state (io_state state)
 
io_state state () const
 
void set_header (std::string header, std::string value)
 
const std::string & header (std::string name) const
 
std::size_t content_length () const
 
const char * content_p () const
 
std::size_t write (std::string s)
 
std::size_t write (const std::string &s)
 
std::size_t write (const char *data, std::size_t size)
 
std::size_t read (char *data, std::size_t size)
 
std::istream & content_istream ()
 
std::ostream & content_ostream ()
 
virtual void prepare_data_buffer ()=0
 Prepare a HTTP request/response to be sent. More...
 
void write_data (socket &sock)
 Write a HTTP object to a socket. More...
 
void print () const
 
bool done () const
 
virtual void clear ()
 Reset the http object. More...
 

Static Public Attributes

static const std::string NO_VAL
 

Protected Member Functions

void write_headers (socket &sock)
 
void write_content (socket &sock)
 

Protected Attributes

tasks::tools::buffer m_data_buffer
 
tasks::tools::buffer m_content_buffer
 
io_state m_state = io_state::READY
 
std::unordered_map
< std::string, std::string > 
m_headers
 
std::size_t m_content_length = 0
 
std::istream m_content_istream
 
std::ostream m_content_ostream
 

Detailed Description

Definition at line 30 of file http_base.h.

Constructor & Destructor Documentation

tasks::net::http_base::http_base ( )
inline

Definition at line 34 of file http_base.h.

virtual tasks::net::http_base::~http_base ( )
inlinevirtual

Definition at line 36 of file http_base.h.

Member Function Documentation

virtual void tasks::net::http_base::clear ( )
inlinevirtual

Reset the http object.

Reimplemented in tasks::net::http_request, and tasks::net::http_response.

Definition at line 119 of file http_base.h.

Here is the call graph for this function:

Here is the caller graph for this function:

std::istream& tasks::net::http_base::content_istream ( )
inline
Returns
An std::istream to access the content buffer.

Definition at line 97 of file http_base.h.

std::size_t tasks::net::http_base::content_length ( ) const
inline
Returns
The content length.

Definition at line 64 of file http_base.h.

std::ostream& tasks::net::http_base::content_ostream ( )
inline
Returns
An std::ostream to access the content buffer.

Definition at line 100 of file http_base.h.

const char* tasks::net::http_base::content_p ( ) const
inline
Returns
A pointer to the content buffer if it contains data or nullptr if it is empty.

Definition at line 67 of file http_base.h.

Here is the call graph for this function:

Here is the caller graph for this function:

bool tasks::net::http_base::done ( ) const
inline
Returns
True after an HTTP object has been read from a socket and parsed or written to a socket.

Definition at line 116 of file http_base.h.

Here is the caller graph for this function:

const std::string& tasks::net::http_base::header ( std::string  name) const
inline
Parameters
nameThe header name.
Returns
The header value.

Definition at line 55 of file http_base.h.

Here is the caller graph for this function:

virtual void tasks::net::http_base::prepare_data_buffer ( )
pure virtual

Prepare a HTTP request/response to be sent.

Implemented in tasks::net::http_request, and tasks::net::http_response.

Here is the caller graph for this function:

void tasks::net::http_base::print ( ) const
inline

Definition at line 108 of file http_base.h.

Here is the call graph for this function:

std::size_t tasks::net::http_base::read ( char *  data,
std::size_t  size 
)
inline

Copy data from the content buffer into a destination buffer.

Parameters
dataA pointer to the destination.
sizeThe number of bytes to copy.

Definition at line 94 of file http_base.h.

Here is the call graph for this function:

void tasks::net::http_base::set_header ( std::string  header,
std::string  value 
)
inline

Set an HTTP header.

Parameters
headerThe header name.
valueThe header value.

Definition at line 46 of file http_base.h.

Here is the call graph for this function:

Here is the caller graph for this function:

void tasks::net::http_base::set_state ( io_state  state)
inline

Definition at line 38 of file http_base.h.

Here is the call graph for this function:

io_state tasks::net::http_base::state ( ) const
inline

Definition at line 40 of file http_base.h.

Here is the caller graph for this function:

std::size_t tasks::net::http_base::write ( std::string  s)
inline

Write a string to the content buffer.

Parameters
sThe string to copy.

Definition at line 77 of file http_base.h.

Here is the call graph for this function:

std::size_t tasks::net::http_base::write ( const std::string &  s)
inline

Write a string to the content buffer.

Parameters
sThe string to copy.

Definition at line 82 of file http_base.h.

Here is the call graph for this function:

std::size_t tasks::net::http_base::write ( const char *  data,
std::size_t  size 
)
inline

Write data to the content buffer.

Parameters
dataA pointer to the source data.
sizeThe number of bytes to copy.

Definition at line 88 of file http_base.h.

Here is the call graph for this function:

void tasks::net::http_base::write_content ( socket sock)
protected

Definition at line 53 of file http_base.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void tasks::net::http_base::write_data ( socket sock)

Write a HTTP object to a socket.

Definition at line 19 of file http_base.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void tasks::net::http_base::write_headers ( socket sock)
protected

Definition at line 45 of file http_base.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

tasks::tools::buffer tasks::net::http_base::m_content_buffer
protected

Definition at line 131 of file http_base.h.

std::istream tasks::net::http_base::m_content_istream
protected

Definition at line 135 of file http_base.h.

std::size_t tasks::net::http_base::m_content_length = 0
protected

Definition at line 134 of file http_base.h.

std::ostream tasks::net::http_base::m_content_ostream
protected

Definition at line 136 of file http_base.h.

tasks::tools::buffer tasks::net::http_base::m_data_buffer
protected

Definition at line 130 of file http_base.h.

std::unordered_map<std::string, std::string> tasks::net::http_base::m_headers
protected

Definition at line 133 of file http_base.h.

io_state tasks::net::http_base::m_state = io_state::READY
protected

Definition at line 132 of file http_base.h.

const std::string tasks::net::http_base::NO_VAL
static

Definition at line 32 of file http_base.h.


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