mastodonpp
0.5.5
|
Represents a connection to an instance. Used for requests. More...
#include <mastodonpp/connection.hpp>
Public Member Functions | |
Connection (const Instance &instance) | |
Construct a new Connection object. More... | |
Connection (const Connection &other)=default | |
Copy constructor. A new CURLWrapper is constructed. More... | |
Connection (Connection &&other) noexcept=delete | |
Move constructor. More... | |
~Connection () noexcept override=default | |
Destructor. More... | |
Connection & | operator= (const Connection &other)=delete |
Copy assignment operator. More... | |
Connection & | operator= (Connection &&other) noexcept=delete |
Move assignment operator. More... | |
answer_type | get (const endpoint_variant &endpoint, const parametermap ¶meters) |
Make a HTTP GET call with parameters. More... | |
answer_type | get (const endpoint_variant &endpoint) |
Make a HTTP GET call. More... | |
answer_type | post (const endpoint_variant &endpoint, const parametermap ¶meters) |
Make a HTTP POST call with parameters. More... | |
answer_type | post (const endpoint_variant &endpoint) |
Make a HTTP POST call. More... | |
answer_type | patch (const endpoint_variant &endpoint, const parametermap ¶meters) |
Make a HTTP PATCH call with parameters. More... | |
answer_type | patch (const endpoint_variant &endpoint) |
Make a HTTP PATCH call. More... | |
answer_type | put (const endpoint_variant &endpoint, const parametermap ¶meters) |
Make a HTTP PUT call with parameters. More... | |
answer_type | put (const endpoint_variant &endpoint) |
Make a HTTP PUT call. More... | |
answer_type | del (const endpoint_variant &endpoint, const parametermap ¶meters) |
Make a HTTP DELETE call with parameters. More... | |
answer_type | del (const endpoint_variant &endpoint) |
Make a HTTP DELETE call. More... | |
string | get_new_stream_contents () |
Copy new stream contents and delete the “original”. More... | |
vector< event_type > | get_new_events () |
Get new stream events. More... | |
void | cancel_stream () |
Cancel the stream. More... | |
Public Member Functions inherited from mastodonpp::CURLWrapper | |
CURLWrapper () | |
Initializes curl and sets up connection. More... | |
CURLWrapper (const CURLWrapper &) | |
Copy constructor. Does the same as the Constructor. More... | |
CURLWrapper (CURLWrapper &&other) noexcept=delete | |
Move constructor. More... | |
virtual | ~CURLWrapper () noexcept |
Cleans up curl and connection. More... | |
CURLWrapper & | operator= (const CURLWrapper &other)=delete |
Copy assignment operator. More... | |
CURLWrapper & | operator= (CURLWrapper &&other) noexcept=delete |
Move assignment operator. More... | |
CURL * | get_curl_easy_handle () |
Returns pointer to the CURL easy handle. More... | |
string | escape_url (const string_view url) const |
URL encodes the given string. More... | |
string | unescape_url (const string_view url) const |
URL decodes the given string. More... | |
void | setup_connection_properties (string_view proxy, string_view access_token, string_view cainfo, string_view useragent) |
Set some properties of the connection. More... | |
Additional Inherited Members | |
Protected Member Functions inherited from mastodonpp::CURLWrapper | |
answer_type | make_request (const http_method &method, string uri, const parametermap ¶meters) |
Make a HTTP request. More... | |
string & | get_buffer () |
Returns a reference to the buffer libcurl writes into. More... | |
void | cancel_stream () |
Cancel the stream. More... | |
virtual void | set_proxy (string_view proxy) |
Set the proxy to use. More... | |
void | set_access_token (string_view access_token) |
Set OAuth 2.0 Bearer Access Token. More... | |
virtual void | set_cainfo (string_view path) |
Set path to Certificate Authority (CA) bundle. More... | |
virtual void | set_useragent (string_view useragent) |
Sets the User-Agent. More... | |
Protected Attributes inherited from mastodonpp::CURLWrapper | |
mutex | _buffer_mutex |
Mutex for get_buffer a.k.a. _curl_buffer_body. More... | |
Represents a connection to an instance. Used for requests.
Do not make 2 requests with the same Connection at the same time. You can create as many Connections as you want from one Instance.
|
inlineexplicit |
|
default |
Copy constructor. A new CURLWrapper is constructed.
|
deletenoexcept |
Move constructor.
|
overridedefaultnoexcept |
Destructor.
|
inline |
Cancel the stream.
The stream will be cancelled, usually whithin a second. The curl_error_code of the answer will be set to 42 (CURLE_ABORTED_BY_CALLBACK
).
|
inline |
Make a HTTP DELETE call.
endpoint | Endpoint as API::endpoint_type or std::string_view . |
answer_type mastodonpp::Connection::del | ( | const endpoint_variant & | endpoint, |
const parametermap & | parameters | ||
) |
Make a HTTP DELETE call with parameters.
endpoint | Endpoint as API::endpoint_type or std::string_view . |
parameters | A map of parameters. |
|
inline |
Make a HTTP GET call.
Example:
endpoint | Endpoint as API::endpoint_type or std::string_view . |
answer_type mastodonpp::Connection::get | ( | const endpoint_variant & | endpoint, |
const parametermap & | parameters | ||
) |
Make a HTTP GET call with parameters.
Example:
endpoint | Endpoint as API::endpoint_type or std::string_view . |
parameters | A map of parameters. |
vector< event_type > mastodonpp::Connection::get_new_events | ( | ) |
Get new stream events.
string mastodonpp::Connection::get_new_stream_contents | ( | ) |
Copy new stream contents and delete the “original”.
Note that the last event is not necessarily complete, it could happen that you are calling this function mid-transfer. You have to check the data integrity yourself.
Using get_new_events() instead is recommended.
|
deletenoexcept |
Move assignment operator.
|
delete |
Copy assignment operator.
|
inline |
Make a HTTP PATCH call.
endpoint | Endpoint as API::endpoint_type or std::string_view . |
answer_type mastodonpp::Connection::patch | ( | const endpoint_variant & | endpoint, |
const parametermap & | parameters | ||
) |
Make a HTTP PATCH call with parameters.
endpoint | Endpoint as API::endpoint_type or std::string_view . |
parameters | A map of parameters. |
|
inline |
Make a HTTP POST call.
endpoint | Endpoint as API::endpoint_type or std::string_view . |
answer_type mastodonpp::Connection::post | ( | const endpoint_variant & | endpoint, |
const parametermap & | parameters | ||
) |
Make a HTTP POST call with parameters.
Example:
endpoint | Endpoint as API::endpoint_type or std::string_view . |
parameters | A map of parameters. |
|
inline |
Make a HTTP PUT call.
endpoint | Endpoint as API::endpoint_type or std::string_view . |
answer_type mastodonpp::Connection::put | ( | const endpoint_variant & | endpoint, |
const parametermap & | parameters | ||
) |
Make a HTTP PUT call with parameters.
endpoint | Endpoint as API::endpoint_type or std::string_view . |
parameters | A map of parameters. |