D++ (DPP)
C++ Discord API Bot Library
dpp::http_request Class Reference

A HTTP request. More...

#include <queues.h>

+ Collaboration diagram for dpp::http_request:

Public Member Functions

 http_request (const std::string &_endpoint, const std::string &_parameters, http_completion_event completion, const std::string &_postdata="", http_method method=m_get, const std::string &filename="", const std::string &filecontent="")
 
 ~http_request ()
 
void complete (const http_request_completion_t &c)
 
http_request_completion_t Run (const class cluster *owner)
 
bool is_completed ()
 

Public Attributes

std::string endpoint
 
std::string parameters
 
std::string postdata
 
http_method method
 
std::string file_name
 
std::string file_content
 

Detailed Description

A HTTP request.

You should instantiate one of these objects via its constructor, and pass a pointer to it into an instance of request_queue. Although you can directly call the Run() method of the object and it will make a HTTP call, be aware that if you do this, it will be a BLOCKING call (not asynchronous) and will not respect rate limits, as both of these functions are managed by the request_queue class.

Constructor & Destructor Documentation

◆ http_request()

dpp::http_request::http_request ( const std::string &  _endpoint,
const std::string &  _parameters,
http_completion_event  completion,
const std::string &  _postdata = "",
http_method  method = m_get,
const std::string &  filename = "",
const std::string &  filecontent = "" 
)

Constructor. When constructing one of these objects it should be passed to request_queue::post_request().

Parameters
_endpointThe API endpoint, e.g. /api/guilds
_parametersMajor and minor parameters for the endpoint e.g. a user id or guild id
completioncompletion event to call when done
_postdataData to send in POST and PUT requests
methodThe HTTP method to use from dpp::http_method
filenameThe filename (server side) of any uploaded file
filecontentThe binary content of any uploaded file for the request

◆ ~http_request()

dpp::http_request::~http_request ( )

Destructor

Member Function Documentation

◆ complete()

void dpp::http_request::complete ( const http_request_completion_t c)

Call the completion callback, if the request is complete.

Parameters
ccallback to call

◆ is_completed()

bool dpp::http_request::is_completed ( )

Returns true if the request is complete

◆ Run()

http_request_completion_t dpp::http_request::Run ( const class cluster owner)

Execute the HTTP request and mark the request complete.

Parameters
ownercreating cluster

Member Data Documentation

◆ endpoint

std::string dpp::http_request::endpoint

Endpoint name e.g. /api/users

◆ file_content

std::string dpp::http_request::file_content

Upload file contents (binary)

◆ file_name

std::string dpp::http_request::file_name

Upload file name (server side)

◆ method

http_method dpp::http_request::method

HTTP method for request

◆ parameters

std::string dpp::http_request::parameters

Major and minor parameters

◆ postdata

std::string dpp::http_request::postdata

Postdata for POST and PUT

D++ Library version 10.0.35D++ Library version 10.0.34D++ Library version 10.0.33D++ Library version 10.0.32D++ Library version 10.0.31D++ Library version 10.0.30D++ Library version 10.0.29D++ Library version 10.0.28D++ Library version 10.0.27D++ Library version 10.0.26D++ Library version 10.0.25D++ Library version 10.0.24D++ Library version 10.0.23D++ Library version 10.0.22D++ Library version 10.0.21D++ Library version 10.0.20D++ Library version 10.0.19D++ Library version 10.0.18D++ Library version 10.0.17D++ Library version 10.0.16D++ Library version 10.0.15D++ Library version 10.0.14D++ Library version 10.0.13D++ Library version 10.0.12D++ Library version 10.0.11D++ Library version 10.0.10D++ Library version 10.0.9D++ Library version 10.0.8D++ Library version 10.0.7D++ Library version 10.0.6D++ Library version 10.0.5D++ Library version 10.0.4D++ Library version 10.0.3D++ Library version 10.0.2D++ Library version 10.0.1D++ Library version 10.0.0D++ Library version 9.0.19D++ Library version 9.0.18D++ Library version 9.0.17D++ Library version 9.0.16D++ Library version 9.0.15D++ Library version 9.0.14D++ Library version 9.0.13D++ Library version 9.0.12D++ Library version 9.0.11D++ Library version 9.0.10D++ Library version 9.0.9D++ Library version 9.0.8D++ Library version 9.0.7D++ Library version 9.0.6D++ Library version 9.0.5D++ Library version 9.0.4D++ Library version 9.0.3D++ Library version 9.0.2D++ Library version 9.0.1D++ Library version 9.0.0D++ Library version 1.0.2D++ Library version 1.0.1D++ Library version 1.0.0