libtasks Documentation  1.6
tasks::net::http_request Class Reference

The HTTP request implementation. More...

#include <http_request.h>

Inheritance diagram for tasks::net::http_request:
Collaboration diagram for tasks::net::http_request:

Public Member Functions

 http_request (std::string host, std::string url="", int port=80)
 
void set_host (std::string host)
 Set the host. More...
 
void set_url (std::string url)
 Set the URL. More...
 
void set_port (int port)
 Set the port. More...
 
const std::string & host () const
 
const std::string & url () const
 
int port () const
 
void prepare_data_buffer ()
 Prepare a HTTP request/response to be sent. More...
 
void clear ()
 Reset the http object. More...
 
- Public Member Functions inherited from tasks::net::http_base
 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 ()
 
void write_data (socket &sock)
 Write a HTTP object to a socket. More...
 
void print () const
 
bool done () const
 

Private Member Functions

void init_default_headers ()
 

Private Attributes

std::string m_host
 
std::string m_url
 
int m_port
 

Additional Inherited Members

- Static Public Attributes inherited from tasks::net::http_base
static const std::string NO_VAL
 
- Protected Member Functions inherited from tasks::net::http_base
void write_headers (socket &sock)
 
void write_content (socket &sock)
 
- Protected Attributes inherited from tasks::net::http_base
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

The HTTP request implementation.

Definition at line 17 of file http_request.h.

Constructor & Destructor Documentation

tasks::net::http_request::http_request ( std::string  host,
std::string  url = "",
int  port = 80 
)
inline

Constructor

Parameters
hostThe host
urlThe URL
portThe port

Definition at line 24 of file http_request.h.

Here is the call graph for this function:

Member Function Documentation

void tasks::net::http_request::clear ( )
inlinevirtual

Reset the http object.

Reimplemented from tasks::net::http_base.

Definition at line 51 of file http_request.h.

Here is the call graph for this function:

const std::string& tasks::net::http_request::host ( ) const
inline
Returns
the host.

Definition at line 39 of file http_request.h.

Here is the caller graph for this function:

void tasks::net::http_request::init_default_headers ( )
private

Definition at line 13 of file http_request.cpp.

Here is the caller graph for this function:

int tasks::net::http_request::port ( ) const
inline
Returns
the port.

Definition at line 45 of file http_request.h.

Here is the caller graph for this function:

void tasks::net::http_request::prepare_data_buffer ( )
virtual

Prepare a HTTP request/response to be sent.

Implements tasks::net::http_base.

Definition at line 15 of file http_request.cpp.

Here is the call graph for this function:

void tasks::net::http_request::set_host ( std::string  host)
inline

Set the host.

Definition at line 30 of file http_request.h.

Here is the call graph for this function:

void tasks::net::http_request::set_port ( int  port)
inline

Set the port.

Definition at line 36 of file http_request.h.

Here is the call graph for this function:

void tasks::net::http_request::set_url ( std::string  url)
inline

Set the URL.

Definition at line 33 of file http_request.h.

Here is the call graph for this function:

const std::string& tasks::net::http_request::url ( ) const
inline
Returns
the URL.

Definition at line 42 of file http_request.h.

Here is the caller graph for this function:

Member Data Documentation

std::string tasks::net::http_request::m_host
private

Definition at line 58 of file http_request.h.

int tasks::net::http_request::m_port
private

Definition at line 60 of file http_request.h.

std::string tasks::net::http_request::m_url
private

Definition at line 59 of file http_request.h.


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