Kagome
Polkadot Runtime Engine in C++17
kagome::offchain::HttpRequest Class Referencefinal

#include <http_request.hpp>

Inheritance diagram for kagome::offchain::HttpRequest:
Collaboration diagram for kagome::offchain::HttpRequest:

Public Member Functions

 HttpRequest (HttpRequest &&) noexcept=delete
 
 HttpRequest (const HttpRequest &)=delete
 
 HttpRequest (RequestId id)
 
RequestId id () const
 
HttpStatus status () const
 
bool init (HttpMethod method, std::string_view uri, common::Buffer meta)
 
Result< Success, FailureaddRequestHeader (std::string_view name, std::string_view value)
 
Result< Success, HttpErrorwriteRequestBody (const common::Buffer &chunk, std::optional< std::chrono::milliseconds > deadline_opt)
 
std::vector< std::pair< std::string, std::string > > getResponseHeaders () const
 
Result< uint32_t, HttpErrorreadResponseBody (common::Buffer &chunk, std::optional< std::chrono::milliseconds > deadline)
 
std::string errorMessage () const
 

Private Types

using TcpStream = boost::beast::tcp_stream
 
using SslStream = boost::beast::ssl_stream< TcpStream >
 
using TcpStreamPtr = std::unique_ptr< TcpStream >
 
using SslStreamPtr = std::unique_ptr< SslStream >
 

Private Member Functions

void resolve ()
 
void connect ()
 
void handshake ()
 
void sendRequest ()
 
void recvResponse ()
 
void done ()
 

Private Attributes

boost::asio::io_context io_context_
 
int16_t id_
 
boost::asio::ip::tcp::resolver resolver_
 
boost::asio::ssl::context ssl_ctx_
 
boost::variant< TcpStreamPtr, SslStreamPtrstream_
 
common::Uri uri_
 
bool adding_headers_is_allowed_ = true
 
bool request_has_sent_ = false
 
bool secure_ = false
 
uint16_t status_ = 0
 
std::string error_message_
 
boost::beast::flat_buffer buffer_
 
boost::asio::steady_timer deadline_timer_
 
boost::asio::ip::tcp::resolver::iterator resolver_iterator_
 
boost::beast::http::request< boost::beast::http::string_body > request_
 
boost::beast::http::response_parser< boost::beast::http::string_body > parser_
 
boost::beast::http::response< boost::beast::http::string_body > response_
 
bool request_is_ready_ = false
 
bool connected_ = false
 
log::Logger log_
 

Detailed Description

Definition at line 24 of file http_request.hpp.

Member Typedef Documentation

using kagome::offchain::HttpRequest::SslStream = boost::beast::ssl_stream<TcpStream>
private

Definition at line 69 of file http_request.hpp.

using kagome::offchain::HttpRequest::SslStreamPtr = std::unique_ptr<SslStream>
private

Definition at line 71 of file http_request.hpp.

using kagome::offchain::HttpRequest::TcpStream = boost::beast::tcp_stream
private

Definition at line 68 of file http_request.hpp.

using kagome::offchain::HttpRequest::TcpStreamPtr = std::unique_ptr<TcpStream>
private

Definition at line 70 of file http_request.hpp.

Constructor & Destructor Documentation

kagome::offchain::HttpRequest::HttpRequest ( HttpRequest &&  )
deletenoexcept
kagome::offchain::HttpRequest::HttpRequest ( const HttpRequest )
delete
kagome::offchain::HttpRequest::HttpRequest ( RequestId  id)

Definition at line 22 of file http_request.cpp.

Member Function Documentation

Result< Success, Failure > kagome::offchain::HttpRequest::addRequestHeader ( std::string_view  name,
std::string_view  value 
)

Definition at line 379 of file http_request.cpp.

void kagome::offchain::HttpRequest::connect ( )
private

Definition at line 158 of file http_request.cpp.

void kagome::offchain::HttpRequest::done ( )
private

Definition at line 349 of file http_request.cpp.

std::string kagome::offchain::HttpRequest::errorMessage ( ) const
inline

Definition at line 50 of file http_request.hpp.

std::vector< std::pair< std::string, std::string > > kagome::offchain::HttpRequest::getResponseHeaders ( ) const

Definition at line 429 of file http_request.cpp.

void kagome::offchain::HttpRequest::handshake ( )
private

Definition at line 211 of file http_request.cpp.

RequestId kagome::offchain::HttpRequest::id ( ) const

Definition at line 371 of file http_request.cpp.

bool kagome::offchain::HttpRequest::init ( HttpMethod  method,
std::string_view  uri,
common::Buffer  meta 
)

Definition at line 47 of file http_request.cpp.

Result< uint32_t, HttpError > kagome::offchain::HttpRequest::readResponseBody ( common::Buffer chunk,
std::optional< std::chrono::milliseconds >  deadline 
)

Definition at line 438 of file http_request.cpp.

void kagome::offchain::HttpRequest::recvResponse ( )
private

Definition at line 303 of file http_request.cpp.

void kagome::offchain::HttpRequest::resolve ( )
private

Definition at line 110 of file http_request.cpp.

void kagome::offchain::HttpRequest::sendRequest ( )
private

Definition at line 246 of file http_request.cpp.

HttpStatus kagome::offchain::HttpRequest::status ( ) const

Definition at line 375 of file http_request.cpp.

Result< Success, HttpError > kagome::offchain::HttpRequest::writeRequestBody ( const common::Buffer chunk,
std::optional< std::chrono::milliseconds >  deadline_opt 
)

Definition at line 392 of file http_request.cpp.

Member Data Documentation

bool kagome::offchain::HttpRequest::adding_headers_is_allowed_ = true
private

Definition at line 75 of file http_request.hpp.

boost::beast::flat_buffer kagome::offchain::HttpRequest::buffer_
private

Definition at line 80 of file http_request.hpp.

bool kagome::offchain::HttpRequest::connected_ = false
private

Definition at line 88 of file http_request.hpp.

boost::asio::steady_timer kagome::offchain::HttpRequest::deadline_timer_
private

Definition at line 81 of file http_request.hpp.

std::string kagome::offchain::HttpRequest::error_message_
private

Definition at line 79 of file http_request.hpp.

int16_t kagome::offchain::HttpRequest::id_
private

Definition at line 63 of file http_request.hpp.

boost::asio::io_context kagome::offchain::HttpRequest::io_context_
private

Definition at line 62 of file http_request.hpp.

log::Logger kagome::offchain::HttpRequest::log_
private

Definition at line 90 of file http_request.hpp.

boost::beast::http::response_parser<boost::beast::http::string_body> kagome::offchain::HttpRequest::parser_
private

Definition at line 85 of file http_request.hpp.

boost::beast::http::request<boost::beast::http::string_body> kagome::offchain::HttpRequest::request_
private

Definition at line 83 of file http_request.hpp.

bool kagome::offchain::HttpRequest::request_has_sent_ = false
private

Definition at line 76 of file http_request.hpp.

bool kagome::offchain::HttpRequest::request_is_ready_ = false
private

Definition at line 87 of file http_request.hpp.

boost::asio::ip::tcp::resolver kagome::offchain::HttpRequest::resolver_
private

Definition at line 65 of file http_request.hpp.

boost::asio::ip::tcp::resolver::iterator kagome::offchain::HttpRequest::resolver_iterator_
private

Definition at line 82 of file http_request.hpp.

boost::beast::http::response<boost::beast::http::string_body> kagome::offchain::HttpRequest::response_
private

Definition at line 86 of file http_request.hpp.

bool kagome::offchain::HttpRequest::secure_ = false
private

Definition at line 77 of file http_request.hpp.

boost::asio::ssl::context kagome::offchain::HttpRequest::ssl_ctx_
private

Definition at line 66 of file http_request.hpp.

uint16_t kagome::offchain::HttpRequest::status_ = 0
private

Definition at line 78 of file http_request.hpp.

boost::variant<TcpStreamPtr, SslStreamPtr> kagome::offchain::HttpRequest::stream_
private

Definition at line 72 of file http_request.hpp.

common::Uri kagome::offchain::HttpRequest::uri_
private

Definition at line 74 of file http_request.hpp.


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