class
#include <base.hpp>
Connection Contents
A internet connection using libcurl.
It is UNDEFINED BEHAVIOR to call any instance methods until conn->ready() returns true.
Derived classes
- class WebSocketConnection
Constructors, destructors, conversion operators
- Connection(const Connection&) deleted
- Connection(Connection&&) defaulted
- ~Connection() virtual noexcept
- Connection(const std::string& url) protected explicit
- Connection(const std::string& url, CURL* curl_handle) protected
Public functions
- auto operator=(const Connection&) -> Connection& defaulted
- auto operator=(Connection&&) -> Connection& defaulted
- void close() pure virtual
- auto open() const -> bool noexcept
- auto ready() const -> bool noexcept
- auto url() const -> const auto& noexcept
- auto file() const -> FILE* pure virtual noexcept
Protected static functions
- static auto debug_log_callback_(CURL* handle, curl_infotype type, char* raw_data, size_t size, void* userdata) -> int
Protected functions
- void start_() pure virtual
- void clear_error_buffer_() noexcept
- void process_curl_error_(CURLcode error_code)
- auto open() -> bool& noexcept
- auto curl_handle() -> auto* noexcept
Function documentation
raccoon:: web:: Connection:: ~Connection() virtual noexcept
Destructor that cleans up the curl handle.
raccoon:: web:: Connection:: Connection(const std::string& url) explicit protected
Parameters | |
---|---|
url | The url to connect to. |
Create a new connection.
Only for subclasses.
raccoon:: web:: Connection:: Connection(const std::string& url,
CURL* curl_handle) protected
Parameters | |
---|---|
url | The url to connect to. |
curl_handle | The curl handle to use for this request. |
Create a new connection with specified handle.
Only for subclasses.
void raccoon:: web:: Connection:: close() pure virtual
Close the connection.
bool raccoon:: web:: Connection:: open() const noexcept
If our connection is open.
bool raccoon:: web:: Connection:: ready() const noexcept
If our connection has been fully initialized.
const auto& raccoon:: web:: Connection:: url() const noexcept
The URL this connection is for.
FILE* raccoon:: web:: Connection:: file() const pure virtual noexcept
Get a file associated with this request, if there is one.
Otherwise, returns nullptr.
static int raccoon:: web:: Connection:: debug_log_callback_(CURL* handle,
curl_infotype type,
char* raw_data,
size_t size,
void* userdata) protected
Process libcurl debug logs.
void raccoon:: web:: Connection:: start_() pure virtual protected
Start this connection.
void raccoon:: web:: Connection:: clear_error_buffer_() protected noexcept
Clear the libcurl error buffer.
void raccoon:: web:: Connection:: process_curl_error_(CURLcode error_code) protected
Handle any errors in libcurl.