KiCad PCB EDA Suite
|
#include <kicad_curl_easy.h>
Public Member Functions | |
KICAD_CURL_EASY () | |
~KICAD_CURL_EASY () | |
int | Perform () |
Equivalent to curl_easy_perform. More... | |
void | SetHeader (const std::string &aName, const std::string &aValue) |
Set an arbitrary header for the HTTP(s) request. More... | |
bool | SetUserAgent (const std::string &aAgent) |
Set the request user agent. More... | |
bool | SetURL (const std::string &aURL) |
Set the request URL. More... | |
bool | SetFollowRedirects (bool aFollow) |
Enable the following of HTTP(s) and other redirects, by default curl does not follow redirects. More... | |
const std::string | GetErrorText (int aCode) |
Fetch CURL's "friendly" error string for a given error code. More... | |
int | GetTransferTotal (uint64_t &aDownloadedBytes) const |
const std::string & | GetBuffer () |
Return a reference to the received data buffer. More... | |
std::string | Escape (const std::string &aUrl) |
Escapes a string for use as a URL. More... | |
bool | SetTransferCallback (const TRANSFER_CALLBACK &aCallback, size_t aInterval) |
bool | SetOutputStream (const std::ostream *aOutput) |
CURL * | GetCurl () |
Private Member Functions | |
template<typename T > | |
int | setOption (int aOption, T aArg) |
Set a curl option, only supports single parameter curl options. More... | |
Private Attributes | |
CURL * | m_CURL |
curl_slist * | m_headers |
std::string | m_buffer |
std::unique_ptr< CURL_PROGRESS > | progress |
Definition at line 66 of file kicad_curl_easy.h.
KICAD_CURL_EASY::KICAD_CURL_EASY | ( | ) |
Definition at line 115 of file kicad_curl_easy.cpp.
References GetBuildDate(), GetBuildVersion(), GetPlatformGetBitnessName(), m_buffer, m_CURL, Pgm(), setOption(), THROW_IO_ERROR, and write_callback().
KICAD_CURL_EASY::~KICAD_CURL_EASY | ( | ) |
Definition at line 163 of file kicad_curl_easy.cpp.
std::string KICAD_CURL_EASY::Escape | ( | const std::string & | aUrl | ) |
Escapes a string for use as a URL.
Definition at line 254 of file kicad_curl_easy.cpp.
References m_CURL.
Referenced by COMMON_CONTROL::ReportBug().
|
inline |
Return a reference to the received data buffer.
Definition at line 123 of file kicad_curl_easy.h.
References m_buffer.
|
inline |
Definition at line 132 of file kicad_curl_easy.h.
References m_CURL.
const std::string KICAD_CURL_EASY::GetErrorText | ( | int | aCode | ) |
Fetch CURL's "friendly" error string for a given error code.
aCode | is CURL error code. |
Definition at line 198 of file kicad_curl_easy.cpp.
Referenced by PCM_TASK_MANAGER::downloadFile(), and PLUGIN_CONTENT_MANAGER::DownloadToStream().
int KICAD_CURL_EASY::GetTransferTotal | ( | uint64_t & | aDownloadedBytes | ) | const |
Definition at line 289 of file kicad_curl_easy.cpp.
References m_CURL.
Referenced by PCM_TASK_MANAGER::downloadFile().
int KICAD_CURL_EASY::Perform | ( | ) |
Equivalent to curl_easy_perform.
Executes the request that was previously setup.
Definition at line 172 of file kicad_curl_easy.cpp.
References m_buffer, m_CURL, and m_headers.
Referenced by PCM_TASK_MANAGER::downloadFile(), and PLUGIN_CONTENT_MANAGER::DownloadToStream().
bool KICAD_CURL_EASY::SetFollowRedirects | ( | bool | aFollow | ) |
Enable the following of HTTP(s) and other redirects, by default curl does not follow redirects.
aFollow | is a boolean where true will enable following redirects. |
Definition at line 245 of file kicad_curl_easy.cpp.
Referenced by PCM_TASK_MANAGER::downloadFile(), and PLUGIN_CONTENT_MANAGER::DownloadToStream().
void KICAD_CURL_EASY::SetHeader | ( | const std::string & | aName, |
const std::string & | aValue | ||
) |
Set an arbitrary header for the HTTP(s) request.
aName | is the left hand side of the header, i.e. Accept without the colon. |
aValue | is the right hand side of the header, i.e. application/json. |
Definition at line 184 of file kicad_curl_easy.cpp.
References m_headers.
|
private |
Set a curl option, only supports single parameter curl options.
aOption | is CURL option, see CURL manual for options. |
aArg | is the argument being passed to CURL, ensure it is the right type per manual. |
Definition at line 192 of file kicad_curl_easy.cpp.
References m_CURL.
Referenced by KICAD_CURL_EASY(), and SetTransferCallback().
bool KICAD_CURL_EASY::SetOutputStream | ( | const std::ostream * | aOutput | ) |
Definition at line 281 of file kicad_curl_easy.cpp.
References m_CURL, and stream_write_callback().
Referenced by PCM_TASK_MANAGER::downloadFile(), and PLUGIN_CONTENT_MANAGER::DownloadToStream().
bool KICAD_CURL_EASY::SetTransferCallback | ( | const TRANSFER_CALLBACK & | aCallback, |
size_t | aInterval | ||
) |
Definition at line 265 of file kicad_curl_easy.cpp.
References progress, progressinfo(), and setOption().
Referenced by PCM_TASK_MANAGER::downloadFile(), and PLUGIN_CONTENT_MANAGER::DownloadToStream().
bool KICAD_CURL_EASY::SetURL | ( | const std::string & | aURL | ) |
Set the request URL.
aURL | is the URL. |
Definition at line 213 of file kicad_curl_easy.cpp.
References KIPLATFORM::ENV::GetSystemProxyConfig(), KIPLATFORM::ENV::PROXY_CONFIG::host, m_CURL, KIPLATFORM::ENV::PROXY_CONFIG::password, and KIPLATFORM::ENV::PROXY_CONFIG::username.
Referenced by PCM_TASK_MANAGER::downloadFile(), and PLUGIN_CONTENT_MANAGER::DownloadToStream().
bool KICAD_CURL_EASY::SetUserAgent | ( | const std::string & | aAgent | ) |
Set the request user agent.
aAgent | is the string to set for the user agent. |
Definition at line 204 of file kicad_curl_easy.cpp.
|
private |
Definition at line 148 of file kicad_curl_easy.h.
Referenced by GetBuffer(), KICAD_CURL_EASY(), and Perform().
|
private |
Definition at line 146 of file kicad_curl_easy.h.
Referenced by Escape(), GetCurl(), GetTransferTotal(), KICAD_CURL_EASY(), Perform(), setOption(), SetOutputStream(), SetURL(), and ~KICAD_CURL_EASY().
|
private |
Definition at line 147 of file kicad_curl_easy.h.
Referenced by Perform(), SetHeader(), and ~KICAD_CURL_EASY().
|
private |
Definition at line 149 of file kicad_curl_easy.h.
Referenced by SetTransferCallback().