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. | |
void | SetHeader (const std::string &aName, const std::string &aValue) |
Set an arbitrary header for the HTTP(s) request. | |
bool | SetUserAgent (const std::string &aAgent) |
Set the request user agent. | |
bool | SetPostFields (const std::vector< std::pair< std::string, std::string > > &aFields) |
Set fields for application/x-www-form-urlencoded POST request. | |
bool | SetPostFields (const std::string &aField) |
Set the post content body to the string, usually used for json rather than the typical key/value pair. | |
bool | SetURL (const std::string &aURL) |
Set the request URL. | |
bool | SetFollowRedirects (bool aFollow) |
Enable the following of HTTP(s) and other redirects, by default curl does not follow redirects. | |
const std::string | GetErrorText (int aCode) |
Fetch CURL's "friendly" error string for a given error code. | |
int | GetTransferTotal (uint64_t &aDownloadedBytes) const |
const std::string & | GetBuffer () |
Return a reference to the received data buffer. | |
std::string | Escape (const std::string &aUrl) |
Escapes a string for use as a URL. | |
bool | SetTransferCallback (const TRANSFER_CALLBACK &aCallback, size_t aInterval) |
bool | SetOutputStream (const std::ostream *aOutput) |
CURL * | GetCurl () |
int | GetResponseStatusCode () |
Private Member Functions | |
template<typename T > | |
int | setOption (int aOption, T aArg) |
Set a curl option, only supports single parameter curl options. | |
Private Attributes | |
CURL * | m_CURL |
curl_slist * | m_headers |
std::string | m_buffer |
std::unique_ptr< CURL_PROGRESS > | progress |
Definition at line 68 of file kicad_curl_easy.h.
KICAD_CURL_EASY::KICAD_CURL_EASY | ( | ) |
Definition at line 120 of file kicad_curl_easy.cpp.
References GetBuildDate(), GetBuildVersion(), GetPlatformGetBitnessName(), m_buffer, m_CURL, POLICY_KEY_REQUESTS_CURL_REVOKE, setOption(), THROW_IO_ERROR, and write_callback().
KICAD_CURL_EASY::~KICAD_CURL_EASY | ( | ) |
Definition at line 186 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 314 of file kicad_curl_easy.cpp.
References m_CURL.
Referenced by COMMON_CONTROL::ReportBug(), and SetPostFields().
|
inline |
Return a reference to the received data buffer.
Definition at line 141 of file kicad_curl_easy.h.
|
inline |
Definition at line 150 of file kicad_curl_easy.h.
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 227 of file kicad_curl_easy.cpp.
Referenced by PCM_TASK_MANAGER::downloadFile(), PLUGIN_CONTENT_MANAGER::DownloadToStream(), and UPDATE_MANAGER::PostRequest().
int KICAD_CURL_EASY::GetResponseStatusCode | ( | ) |
Definition at line 364 of file kicad_curl_easy.cpp.
References m_CURL.
Referenced by UPDATE_MANAGER::PostRequest().
int KICAD_CURL_EASY::GetTransferTotal | ( | uint64_t & | aDownloadedBytes | ) | const |
Definition at line 349 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 195 of file kicad_curl_easy.cpp.
References m_buffer, m_CURL, m_headers, and KICAD_CURL::Mutex().
Referenced by PCM_TASK_MANAGER::downloadFile(), PLUGIN_CONTENT_MANAGER::DownloadToStream(), and UPDATE_MANAGER::PostRequest().
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 305 of file kicad_curl_easy.cpp.
Referenced by PCM_TASK_MANAGER::downloadFile(), PLUGIN_CONTENT_MANAGER::DownloadToStream(), and UPDATE_MANAGER::PostRequest().
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 213 of file kicad_curl_easy.cpp.
References m_headers.
Referenced by UPDATE_MANAGER::PostRequest().
|
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 221 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 341 of file kicad_curl_easy.cpp.
References m_CURL, and stream_write_callback().
Referenced by PCM_TASK_MANAGER::downloadFile(), PLUGIN_CONTENT_MANAGER::DownloadToStream(), and UPDATE_MANAGER::PostRequest().
bool KICAD_CURL_EASY::SetPostFields | ( | const std::string & | aField | ) |
Set the post content body to the string, usually used for json rather than the typical key/value pair.
aField | is the string body to send |
Definition at line 264 of file kicad_curl_easy.cpp.
bool KICAD_CURL_EASY::SetPostFields | ( | const std::vector< std::pair< std::string, std::string > > & | aFields | ) |
Set fields for application/x-www-form-urlencoded POST request.
aFields | is the vector of fields (key-value pairs). |
Definition at line 242 of file kicad_curl_easy.cpp.
References Escape().
Referenced by UPDATE_MANAGER::PostRequest().
bool KICAD_CURL_EASY::SetTransferCallback | ( | const TRANSFER_CALLBACK & | aCallback, |
size_t | aInterval | ||
) |
Definition at line 325 of file kicad_curl_easy.cpp.
References progress, progressinfo(), and setOption().
Referenced by PCM_TASK_MANAGER::downloadFile(), PLUGIN_CONTENT_MANAGER::DownloadToStream(), and UPDATE_MANAGER::PostRequest().
bool KICAD_CURL_EASY::SetURL | ( | const std::string & | aURL | ) |
Set the request URL.
aURL | is the URL. |
Definition at line 273 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(), PLUGIN_CONTENT_MANAGER::DownloadToStream(), and UPDATE_MANAGER::PostRequest().
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 233 of file kicad_curl_easy.cpp.
|
private |
Definition at line 167 of file kicad_curl_easy.h.
Referenced by KICAD_CURL_EASY(), and Perform().
|
private |
Definition at line 165 of file kicad_curl_easy.h.
Referenced by Escape(), GetResponseStatusCode(), GetTransferTotal(), KICAD_CURL_EASY(), Perform(), setOption(), SetOutputStream(), SetURL(), and ~KICAD_CURL_EASY().
|
private |
Definition at line 166 of file kicad_curl_easy.h.
Referenced by Perform(), SetHeader(), and ~KICAD_CURL_EASY().
|
private |
Definition at line 168 of file kicad_curl_easy.h.
Referenced by SetTransferCallback().