My Project: dht::http::Request Class Reference

My Project 3.7.7 C++ Distributed Hash Table

Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
dht::http::Request Class Reference
Inheritance diagram for dht::http::Request:
[legend]
Collaboration diagram for dht::http::Request:
[legend]

## Public Types
enum class | 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< log::Logger > logger={})
| Request (asio::io_context &ctx, const std::string &url, OnJsonCb jsoncb, std::shared_ptr< log::Logger > logger={})
| Request (asio::io_context &ctx, const std::string &url, std::shared_ptr< log::Logger > logger={})
| Request (asio::io_context &ctx, std::string_view host, std::string_view service, const bool ssl=false, std::shared_ptr< log::Logger > logger={})
| Request (asio::io_context &ctx, const std::string &url, OnDoneCb onDone, std::shared_ptr< log::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< log::Logger > logger={})
unsigned int | id () const
void | set_connection (std::shared_ptr< Connection > connection)
std::shared_ptr< Connection > | get_connection () const
const Url & | get_url () const
void | timeout (const std::chrono::seconds &timeout, HandlerCb cb={})
std::shared_ptr< Request > | getPrevious () 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< log::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_body (const uint8_t *data, size_t length)
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 Response & | await ()
void | cancel ()
void | terminate (const asio::error_code &ec)

## Detailed Description

Definition at line 207 of file http.h.

## Member Typedef Documentation

## ◆ OnDataCb

using dht::http::Request::OnDataCb = std::function<void(const char* at, size_t length)>

Definition at line 212 of file http.h.

## ◆ OnDoneCb

using dht::http::Request::OnDoneCb = std::function<void(const Response& response)>

Definition at line 215 of file http.h.

## ◆ OnJsonCb

using dht::http::Request::OnJsonCb = std::function<void(Json::Value value, const Response& response)>

Definition at line 214 of file http.h.

## ◆ OnStateChangeCb

using dht::http::Request::OnStateChangeCb = std::function<void(State state, const Response& response)>

Definition at line 213 of file http.h.

## ◆ OnStatusCb

using dht::http::Request::OnStatusCb = std::function<void(unsigned status_code)>

Definition at line 211 of file http.h.

## Member Enumeration Documentation

## ◆ State

enum class dht::http::Request::State
| strong

Definition at line 210 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.

## ◆ get_url()

const Url & dht::http::Request::get_url | ( |  | ) | const
| inline

Definition at line 251 of file http.h.

## ◆ getPrevious()

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

The previous request in case of redirect following

Definition at line 260 of file http.h.

## ◆ id()

unsigned int dht::http::Request::id | ( |  | ) | const
| inline

Definition at line 248 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.

## ◆ timeout()

void dht::http::Request::timeout | ( | const std::chrono::seconds & | timeout,
|  | HandlerCb | cb = {} )
| inline

Definition at line 253 of file http.h.

## ◆ to_string()

std::string & dht::http::Request::to_string | ( |  | ) |
| inline

Definition at line 262 of file http.h.

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

- /home/noptrix/ba/blackarch/packages/opendht-c/src/opendht/include/opendht/http.h