C++ Distributed Hash Table
Classes | Public Types | Public Member Functions | List of all members
dht::http::Request Class Reference
Inheritance diagram for dht::http::Request:
Inheritance graph
[legend]
Collaboration diagram for dht::http::Request:
Collaboration graph
[legend]

Public Types

enum  State {
  CREATED, SENDING, HEADER_RECEIVED, RECEIVING,
  DONE
}
 
using OnStatusCb = std::function< void(unsigned status_code)>
 
using OnDataCb = std::function< void(const char *at, size_t length)>
 
using OnStateChangeCb = std::function< void(State state, const Response &response)>
 
using OnJsonCb = std::function< void(Json::Value value, const Response &response)>
 
using OnDoneCb = std::function< void(const Response &response)>
 

Public Member Functions

 Request (asio::io_context &ctx, const std::string &url, const Json::Value &json, OnJsonCb jsoncb, std::shared_ptr< dht::Logger > logger={})
 
 Request (asio::io_context &ctx, const std::string &url, OnJsonCb jsoncb, std::shared_ptr< dht::Logger > logger={})
 
 Request (asio::io_context &ctx, const std::string &url, std::shared_ptr< dht::Logger > logger={})
 
 Request (asio::io_context &ctx, const std::string &host, const std::string &service, const bool ssl=false, std::shared_ptr< dht::Logger > logger={})
 
 Request (asio::io_context &ctx, const std::string &url, OnDoneCb onDone, std::shared_ptr< dht::Logger > logger={})
 
 Request (asio::io_context &ctx, std::shared_ptr< Resolver > resolver, sa_family_t family=AF_UNSPEC)
 
 Request (asio::io_context &ctx, std::shared_ptr< Resolver > resolver, const std::string &target, sa_family_t family=AF_UNSPEC)
 
 Request (asio::io_context &ctx, std::vector< asio::ip::tcp::endpoint > &&endpoints, const bool ssl=false, std::shared_ptr< dht::Logger > logger={})
 
unsigned int id () const
 
void set_connection (std::shared_ptr< Connection > connection)
 
std::shared_ptr< Connectionget_connection () const
 
const Urlget_url () const
 
std::shared_ptr< RequestgetPrevious () const
 
std::string & to_string ()
 
void set_certificate_authority (std::shared_ptr< dht::crypto::Certificate > certificate)
 
void set_identity (const dht::crypto::Identity &identity)
 
void set_logger (std::shared_ptr< dht::Logger > logger)
 
void set_header (restinio::http_request_header_t header)
 
void set_method (restinio::http_method_id_t method)
 
void set_target (std::string target)
 
void set_header_field (restinio::http_field_t field, std::string value)
 
void set_connection_type (restinio::http_connection_header_t connection)
 
void set_body (std::string body)
 
void set_auth (const std::string &username, const std::string &password)
 
void add_on_status_callback (OnStatusCb cb)
 
void add_on_body_callback (OnDataCb cb)
 
void add_on_state_change_callback (OnStateChangeCb cb)
 
void add_on_done_callback (OnDoneCb cb)
 
void send ()
 
const Responseawait ()
 
void cancel ()
 
void terminate (const asio::error_code &ec)
 

Detailed Description

Definition at line 220 of file http.h.

Member Function Documentation

◆ await()

const Response& dht::http::Request::await ( )

Send and block for response

◆ cancel()

void dht::http::Request::cancel ( )

User action to cancel the Request and call the completion callbacks.

◆ getPrevious()

std::shared_ptr<Request> dht::http::Request::getPrevious ( ) const
inline

The previous request in case of redirect following

Definition at line 265 of file http.h.

◆ set_header()

void dht::http::Request::set_header ( restinio::http_request_header_t  header)

Define the HTTP header/body as per https://tools.ietf.org/html/rfc7230.


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