Guitar
Classes | Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
WebClient Class Reference

#include <webclient.h>

Collaboration diagram for WebClient:
Collaboration graph
[legend]

Classes

struct  Authorization
 
struct  ContentDisposition
 
class  ContentType
 
class  Error
 
struct  Part
 
struct  Post
 
struct  Private
 
class  Request
 
struct  RequestOption
 
struct  Response
 
class  URL
 

Public Types

enum  HttpVersion { HTTP_1_0, HTTP_1_1 }
 

Public Member Functions

 WebClient (WebContext *webcx)
 
 ~WebClient ()
 
 WebClient (WebClient const &)=delete
 
void operator= (WebClient const &)=delete
 
void set_http_version (HttpVersion httpver)
 
const Errorerror () const
 
int get (const Request &req, WebClientHandler *handler=nullptr)
 
int post (const Request &req, Post const *post, WebClientHandler *handler=nullptr)
 
void close ()
 
void add_header (std::string const &text)
 
const Responseresponse () const
 
std::string header_value (std::string const &name) const
 
std::string content_type () const
 
size_t content_length () const
 
const char * content_data () const
 

Static Public Member Functions

static void initialize ()
 
static void make_application_www_form_urlencoded (char const *begin, char const *end, WebClient::Post *out)
 
static void make_multipart_form_data (const std::vector< Part > &parts, WebClient::Post *out, std::string const &boundary)
 
static void make_multipart_form_data (char const *data, size_t size, WebClient::Post *out, std::string const &boundary)
 
static std::string get (const std::string &url)
 
static std::string checkip ()
 

Private Member Functions

void clear_error ()
 
void set_default_header (const Request &url, Post const *post, const RequestOption &opt)
 
std::string make_http_request (const Request &url, Post const *post, const WebProxy *proxy, bool https)
 
void parse_http_header (char const *begin, char const *end, std::vector< std::string > *header)
 
void parse_http_header (char const *begin, char const *end, Response *out)
 
bool http_get (const Request &request_req, Post const *post, RequestOption const &opt, ResponseHeader *rh, std::vector< char > *out)
 
bool https_get (const Request &request_url, Post const *post, RequestOption const &opt, ResponseHeader *rh, std::vector< char > *out)
 
bool get (const Request &req, Post const *post, Response *out, WebClientHandler *handler)
 
void append (char const *ptr, size_t len, std::vector< char > *out, WebClientHandler *handler)
 
void on_end_header (const std::vector< char > *vec, WebClientHandler *handler)
 
void receive_ (const RequestOption &opt, std::function< int(char *, int)> const &, ResponseHeader *rh, std::vector< char > *out)
 
void output_debug_string (char const *str)
 
void output_debug_strings (const std::vector< std::string > &vec)
 
void reset ()
 

Static Private Member Functions

static int get_port (URL const *url, char const *scheme, char const *protocol)
 
static void parse_header (std::vector< std::string > const *header, WebClient::Response *res)
 
static std::string header_value (std::vector< std::string > const *header, std::string const &name)
 
static void cleanup ()
 

Private Attributes

Privatem
 

Member Enumeration Documentation

◆ HttpVersion

Enumerator
HTTP_1_0 
HTTP_1_1 

Constructor & Destructor Documentation

◆ WebClient() [1/2]

WebClient::WebClient ( WebContext webcx)
Here is the call graph for this function:

◆ ~WebClient()

WebClient::~WebClient ( )
Here is the call graph for this function:

◆ WebClient() [2/2]

WebClient::WebClient ( WebClient const &  )
delete

Member Function Documentation

◆ add_header()

void WebClient::add_header ( std::string const &  text)

◆ append()

void WebClient::append ( char const *  ptr,
size_t  len,
std::vector< char > *  out,
WebClientHandler handler 
)
private
Here is the call graph for this function:

◆ checkip()

std::string WebClient::checkip ( )
static
Here is the call graph for this function:

◆ cleanup()

void WebClient::cleanup ( )
staticprivate

◆ clear_error()

void WebClient::clear_error ( )
private

◆ close()

void WebClient::close ( )

◆ content_data()

const char * WebClient::content_data ( ) const

◆ content_length()

size_t WebClient::content_length ( ) const

◆ content_type()

std::string WebClient::content_type ( ) const
Here is the call graph for this function:

◆ error()

const WebClient::Error & WebClient::error ( ) const

◆ get() [1/3]

bool WebClient::get ( const Request req,
Post const *  post,
Response out,
WebClientHandler handler 
)
private
Here is the call graph for this function:

◆ get() [2/3]

int WebClient::get ( const Request req,
WebClientHandler handler = nullptr 
)
Here is the call graph for this function:

◆ get() [3/3]

std::string WebClient::get ( const std::string &  url)
static
Here is the call graph for this function:

◆ get_port()

int WebClient::get_port ( URL const *  url,
char const *  scheme,
char const *  protocol 
)
staticprivate
Here is the call graph for this function:

◆ header_value() [1/2]

std::string WebClient::header_value ( std::string const &  name) const
Here is the call graph for this function:

◆ header_value() [2/2]

std::string WebClient::header_value ( std::vector< std::string > const *  header,
std::string const &  name 
)
staticprivate

◆ http_get()

bool WebClient::http_get ( const Request request_req,
Post const *  post,
RequestOption const &  opt,
ResponseHeader rh,
std::vector< char > *  out 
)
private
Here is the call graph for this function:

◆ https_get()

bool WebClient::https_get ( const Request request_url,
Post const *  post,
RequestOption const &  opt,
ResponseHeader rh,
std::vector< char > *  out 
)
private
Here is the call graph for this function:

◆ initialize()

void WebClient::initialize ( )
static
Here is the call graph for this function:

◆ make_application_www_form_urlencoded()

void WebClient::make_application_www_form_urlencoded ( char const *  begin,
char const *  end,
WebClient::Post out 
)
static

◆ make_http_request()

std::string WebClient::make_http_request ( const Request url,
Post const *  post,
const WebProxy proxy,
bool  https 
)
private
Here is the call graph for this function:

◆ make_multipart_form_data() [1/2]

void WebClient::make_multipart_form_data ( char const *  data,
size_t  size,
WebClient::Post out,
std::string const &  boundary 
)
static
Here is the call graph for this function:

◆ make_multipart_form_data() [2/2]

void WebClient::make_multipart_form_data ( const std::vector< Part > &  parts,
WebClient::Post out,
std::string const &  boundary 
)
static

◆ on_end_header()

void WebClient::on_end_header ( const std::vector< char > *  vec,
WebClientHandler handler 
)
private
Here is the call graph for this function:

◆ operator=()

void WebClient::operator= ( WebClient const &  )
delete

◆ output_debug_string()

void WebClient::output_debug_string ( char const *  str)
private

◆ output_debug_strings()

void WebClient::output_debug_strings ( const std::vector< std::string > &  vec)
private
Here is the call graph for this function:

◆ parse_header()

void WebClient::parse_header ( std::vector< std::string > const *  header,
WebClient::Response res 
)
staticprivate

◆ parse_http_header() [1/2]

void WebClient::parse_http_header ( char const *  begin,
char const *  end,
WebClient::Response out 
)
private
Here is the call graph for this function:

◆ parse_http_header() [2/2]

void WebClient::parse_http_header ( char const *  begin,
char const *  end,
std::vector< std::string > *  header 
)
private

◆ post()

int WebClient::post ( const Request req,
Post const *  post,
WebClientHandler handler = nullptr 
)
Here is the call graph for this function:

◆ receive_()

void WebClient::receive_ ( const RequestOption opt,
std::function< int(char *, int)> const &  rcv,
ResponseHeader rh,
std::vector< char > *  out 
)
private
Here is the call graph for this function:

◆ reset()

void WebClient::reset ( )
private

◆ response()

const WebClient::Response & WebClient::response ( ) const

◆ set_default_header()

void WebClient::set_default_header ( const Request url,
Post const *  post,
const RequestOption opt 
)
private
Here is the call graph for this function:

◆ set_http_version()

void WebClient::set_http_version ( HttpVersion  httpver)

Member Data Documentation

◆ m

Private* WebClient::m
private

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