OpenSDN source code
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
HttpConnection Class Reference

#include <http_client.h>

Collaboration diagram for HttpConnection:

Public Types

typedef boost::function< void(std::string
&, boost::system::error_code &)> 
HttpCb
 

Public Member Functions

 HttpConnection (boost::asio::ip::tcp::endpoint, size_t id, HttpClient *client)
 
 HttpConnection (const std::string &host, int port, size_t id, HttpClient *client)
 
 ~HttpConnection ()
 
int Initialize ()
 
int HttpPut (const std::string &put_string, const std::string &path, HttpCb)
 
int HttpPut (const std::string &put_string, const std::string &path, bool header, bool short_timeout, bool reuse, std::vector< std::string > &hdr_options, HttpCb cb)
 
int HttpPost (const std::string &post_string, const std::string &path, HttpCb)
 
int HttpPost (const std::string &post_string, const std::string &path, bool header, bool short_timeout, bool reuse, std::vector< std::string > &hdr_options, HttpCb cb)
 
int HttpGet (const std::string &path, HttpCb)
 
int HttpGet (const std::string &path, bool header, bool short_timeout, bool reuse, std::vector< std::string > &hdr_options, HttpCb cb)
 
int HttpHead (const std::string &path, bool header, bool short_timeout, bool reuse, std::vector< std::string > &hdr_options, HttpCb cb)
 
int HttpDelete (const std::string &path, HttpCb)
 
int HttpDelete (const std::string &path, bool header, bool short_timeout, bool reuse, std::vector< std::string > &hdr_options, HttpCb cb)
 
int Status ()
 
std::string Version ()
 
std::string Reason ()
 
std::map< std::string,
std::string > * 
Headers ()
 
void ClearCallback ()
 
struct _ConnInfocurl_handle ()
 
std::map< CURLoption, int > * curl_options ()
 
HttpClientclient ()
 
HttpClientSessionsession ()
 
tbb::mutex & mutex ()
 
boost::asio::ip::tcp::endpoint endpoint ()
 
size_t id ()
 
const std::string & GetData ()
 
void set_curl_handle (struct _ConnInfo *handle)
 
HttpClientSessionCreateSession ()
 
void set_session (HttpClientSession *session)
 
void delete_session ()
 
void AssignData (const char *ptr, size_t size)
 
void AssignHeader (const char *ptr, size_t size)
 
void UpdateOffset (size_t bytes)
 
size_t GetOffset ()
 
HttpCb HttpClientCb ()
 
void RegisterEventCb (HttpClientSession::SessionEventCb cb)
 
void set_use_ssl (bool ssl_flag)
 
bool use_ssl ()
 
void set_client_cert (const std::string &client_cert)
 
void set_client_cert_type (const std::string &client_cert_type)
 
void set_client_key (const std::string &client_key)
 
void set_ca_cert (const std::string &ca_cert)
 

Private Types

enum  HTTPHeaderDataState { STATUS = 142, HEADER }
 

Private Member Functions

std::string make_url (std::string &path)
 
unsigned short bool2bf (bool header, bool short_timeout, bool reuse)
 
void bf2bool (unsigned short bf, bool &header, bool &short_timeout, bool &reuse)
 
void HttpProcessInternal (const std::string body, std::string path, unsigned short header_shortTimeout_reuse, std::vector< std::string > hdr_options, HttpCb cb, http_method m)
 
 DISALLOW_COPY_AND_ASSIGN (HttpConnection)
 

Private Attributes

const std::string host_
 
boost::asio::ip::tcp::endpoint endpoint_
 
size_t id_
 
HttpCb cb_
 
size_t offset_
 
std::string buf_
 
struct _ConnInfocurl_handle_
 
std::map< CURLoption, int > curl_options_
 
HttpClientSessionsession_
 
HttpClientclient_
 
tbb::mutex mutex_
 
HttpClientSession::SessionEventCb event_cb_
 
int status_
 
std::string version_
 
std::string reason_
 
std::map< std::string,
std::string > 
headers_
 
bool sent_hdr_
 
bool use_ssl_
 
std::string client_cert_
 
std::string client_cert_type_
 
std::string client_key_
 
std::string ca_cert_
 
enum
HttpConnection::HTTPHeaderDataState 
state_
 

Detailed Description

Definition at line 62 of file http_client.h.

Member Typedef Documentation

typedef boost::function<void(std::string &, boost::system::error_code &)> HttpConnection::HttpCb

Definition at line 70 of file http_client.h.

Member Enumeration Documentation

Enumerator
STATUS 
HEADER 

Definition at line 172 of file http_client.h.

Constructor & Destructor Documentation

HttpConnection::HttpConnection ( boost::asio::ip::tcp::endpoint  ep,
size_t  id,
HttpClient client 
)

Definition at line 72 of file http_client.cc.

HttpConnection::HttpConnection ( const std::string &  host,
int  port,
size_t  id,
HttpClient client 
)

Definition at line 80 of file http_client.cc.

HttpConnection::~HttpConnection ( )

Definition at line 88 of file http_client.cc.

Here is the call graph for this function:

Member Function Documentation

void HttpConnection::AssignData ( const char *  ptr,
size_t  size 
)

Definition at line 306 of file http_client.cc.

void HttpConnection::AssignHeader ( const char *  ptr,
size_t  size 
)

Definition at line 316 of file http_client.cc.

void HttpConnection::bf2bool ( unsigned short  bf,
bool &  header,
bool &  short_timeout,
bool &  reuse 
)
inlineprivate

Definition at line 137 of file http_client.h.

unsigned short HttpConnection::bool2bf ( bool  header,
bool  short_timeout,
bool  reuse 
)
inlineprivate

Definition at line 133 of file http_client.h.

void HttpConnection::ClearCallback ( )

Definition at line 211 of file http_client.cc.

HttpClient* HttpConnection::client ( )
inline

Definition at line 98 of file http_client.h.

HttpClientSession * HttpConnection::CreateSession ( )

Definition at line 108 of file http_client.cc.

Here is the call graph for this function:

struct _ConnInfo* HttpConnection::curl_handle ( )
inline

Definition at line 96 of file http_client.h.

std::map<CURLoption, int>* HttpConnection::curl_options ( )
inline

Definition at line 97 of file http_client.h.

void HttpConnection::delete_session ( )

Definition at line 117 of file http_client.cc.

Here is the call graph for this function:

HttpConnection::DISALLOW_COPY_AND_ASSIGN ( HttpConnection  )
private
boost::asio::ip::tcp::endpoint HttpConnection::endpoint ( )
inline

Definition at line 101 of file http_client.h.

const std::string & HttpConnection::GetData ( )

Definition at line 361 of file http_client.cc.

size_t HttpConnection::GetOffset ( )

Definition at line 369 of file http_client.cc.

std::map<std::string, std::string>* HttpConnection::Headers ( )
inline

Definition at line 93 of file http_client.h.

HttpCb HttpConnection::HttpClientCb ( )
inline

Definition at line 113 of file http_client.h.

int HttpConnection::HttpDelete ( const std::string &  path,
HttpCb  cb 
)

Definition at line 196 of file http_client.cc.

int HttpConnection::HttpDelete ( const std::string &  path,
bool  header,
bool  short_timeout,
bool  reuse,
std::vector< std::string > &  hdr_options,
HttpCb  cb 
)

Definition at line 201 of file http_client.cc.

Here is the call graph for this function:

int HttpConnection::HttpGet ( const std::string &  path,
HttpCb  cb 
)

Definition at line 135 of file http_client.cc.

int HttpConnection::HttpGet ( const std::string &  path,
bool  header,
bool  short_timeout,
bool  reuse,
std::vector< std::string > &  hdr_options,
HttpCb  cb 
)

Definition at line 140 of file http_client.cc.

Here is the call graph for this function:

int HttpConnection::HttpHead ( const std::string &  path,
bool  header,
bool  short_timeout,
bool  reuse,
std::vector< std::string > &  hdr_options,
HttpCb  cb 
)

Definition at line 152 of file http_client.cc.

Here is the call graph for this function:

int HttpConnection::HttpPost ( const std::string &  post_string,
const std::string &  path,
HttpCb  cb 
)

Definition at line 180 of file http_client.cc.

int HttpConnection::HttpPost ( const std::string &  post_string,
const std::string &  path,
bool  header,
bool  short_timeout,
bool  reuse,
std::vector< std::string > &  hdr_options,
HttpCb  cb 
)

Definition at line 186 of file http_client.cc.

Here is the call graph for this function:

void HttpConnection::HttpProcessInternal ( const std::string  body,
std::string  path,
unsigned short  header_shortTimeout_reuse,
std::vector< std::string >  hdr_options,
HttpCb  cb,
http_method  m 
)
private

Definition at line 215 of file http_client.cc.

Here is the call graph for this function:

int HttpConnection::HttpPut ( const std::string &  put_string,
const std::string &  path,
HttpCb  cb 
)

Definition at line 162 of file http_client.cc.

int HttpConnection::HttpPut ( const std::string &  put_string,
const std::string &  path,
bool  header,
bool  short_timeout,
bool  reuse,
std::vector< std::string > &  hdr_options,
HttpCb  cb 
)

Definition at line 168 of file http_client.cc.

Here is the call graph for this function:

size_t HttpConnection::id ( )
inline

Definition at line 102 of file http_client.h.

int HttpConnection::Initialize ( )
std::string HttpConnection::make_url ( std::string &  path)
private

Definition at line 92 of file http_client.cc.

tbb::mutex& HttpConnection::mutex ( )
inline

Definition at line 100 of file http_client.h.

std::string HttpConnection::Reason ( )
inline

Definition at line 92 of file http_client.h.

void HttpConnection::RegisterEventCb ( HttpClientSession::SessionEventCb  cb)
inline

Definition at line 114 of file http_client.h.

HttpClientSession* HttpConnection::session ( )
inline

Definition at line 99 of file http_client.h.

void HttpConnection::set_ca_cert ( const std::string &  ca_cert)
inline

Definition at line 126 of file http_client.h.

void HttpConnection::set_client_cert ( const std::string &  client_cert)
inline

Definition at line 117 of file http_client.h.

void HttpConnection::set_client_cert_type ( const std::string &  client_cert_type)
inline

Definition at line 120 of file http_client.h.

void HttpConnection::set_client_key ( const std::string &  client_key)
inline

Definition at line 123 of file http_client.h.

void HttpConnection::set_curl_handle ( struct _ConnInfo handle)
inline

Definition at line 105 of file http_client.h.

void HttpConnection::set_session ( HttpClientSession session)

Definition at line 129 of file http_client.cc.

Here is the call graph for this function:

void HttpConnection::set_use_ssl ( bool  ssl_flag)
inline

Definition at line 115 of file http_client.h.

int HttpConnection::Status ( )
inline

Definition at line 90 of file http_client.h.

void HttpConnection::UpdateOffset ( size_t  bytes)

Definition at line 365 of file http_client.cc.

bool HttpConnection::use_ssl ( )
inline

Definition at line 116 of file http_client.h.

std::string HttpConnection::Version ( )
inline

Definition at line 91 of file http_client.h.

Member Data Documentation

std::string HttpConnection::buf_
private

Definition at line 155 of file http_client.h.

std::string HttpConnection::ca_cert_
private

Definition at line 171 of file http_client.h.

HttpCb HttpConnection::cb_
private

Definition at line 153 of file http_client.h.

HttpClient* HttpConnection::client_
private

Definition at line 159 of file http_client.h.

std::string HttpConnection::client_cert_
private

Definition at line 168 of file http_client.h.

std::string HttpConnection::client_cert_type_
private

Definition at line 169 of file http_client.h.

std::string HttpConnection::client_key_
private

Definition at line 170 of file http_client.h.

struct _ConnInfo* HttpConnection::curl_handle_
private

Definition at line 156 of file http_client.h.

std::map<CURLoption, int> HttpConnection::curl_options_
private

Definition at line 157 of file http_client.h.

boost::asio::ip::tcp::endpoint HttpConnection::endpoint_
private

Definition at line 151 of file http_client.h.

HttpClientSession::SessionEventCb HttpConnection::event_cb_
private

Definition at line 161 of file http_client.h.

std::map<std::string, std::string> HttpConnection::headers_
private

Definition at line 165 of file http_client.h.

const std::string HttpConnection::host_
private

Definition at line 150 of file http_client.h.

size_t HttpConnection::id_
private

Definition at line 152 of file http_client.h.

tbb::mutex HttpConnection::mutex_
mutableprivate

Definition at line 160 of file http_client.h.

size_t HttpConnection::offset_
private

Definition at line 154 of file http_client.h.

std::string HttpConnection::reason_
private

Definition at line 164 of file http_client.h.

bool HttpConnection::sent_hdr_
private

Definition at line 166 of file http_client.h.

HttpClientSession* HttpConnection::session_
private

Definition at line 158 of file http_client.h.

enum HttpConnection::HTTPHeaderDataState HttpConnection::state_
private
int HttpConnection::status_
private

Definition at line 162 of file http_client.h.

bool HttpConnection::use_ssl_
private

Definition at line 167 of file http_client.h.

std::string HttpConnection::version_
private

Definition at line 163 of file http_client.h.


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