| 
    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 | 
| std::shared_lock< std::shared_mutex > | m_curlSharedLock | 
Definition at line 69 of file kicad_curl_easy.h.
| KICAD_CURL_EASY::KICAD_CURL_EASY | ( | ) | 
Definition at line 123 of file kicad_curl_easy.cpp.
References BEST_EFFORT, GetBuildDate(), GetBuildVersion(), GetPlatformGetBitnessName(), KIPLATFORM::POLICY::GetPolicyEnum(), m_buffer, m_CURL, m_curlSharedLock, m_headers, NONE, POLICY_KEY_REQUESTS_CURL_REVOKE, setOption(), THROW_IO_ERROR, and write_callback().
| KICAD_CURL_EASY::~KICAD_CURL_EASY | ( | ) | 
Definition at line 191 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 312 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 143 of file kicad_curl_easy.h.
References m_buffer.
      
  | 
  inline | 
Definition at line 152 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 226 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 348 of file kicad_curl_easy.cpp.
References m_CURL, and result.
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 200 of file kicad_curl_easy.cpp.
References m_buffer, m_CURL, and m_headers.
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 303 of file kicad_curl_easy.cpp.
References setOption().
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 212 of file kicad_curl_easy.cpp.
References m_headers.
Referenced by UPDATE_MANAGER::PostRequest().
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 220 of file kicad_curl_easy.cpp.
Referenced by KICAD_CURL_EASY(), SetFollowRedirects(), SetPostFields(), SetPostFields(), SetTransferCallback(), SetURL(), and SetUserAgent().
| bool KICAD_CURL_EASY::SetOutputStream | ( | const std::ostream * | aOutput | ) | 
Definition at line 340 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 262 of file kicad_curl_easy.cpp.
References setOption().
| 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 241 of file kicad_curl_easy.cpp.
References Escape(), and setOption().
Referenced by UPDATE_MANAGER::PostRequest().
| bool KICAD_CURL_EASY::SetTransferCallback | ( | const TRANSFER_CALLBACK & | aCallback, | 
| size_t | aInterval ) | 
Definition at line 323 of file kicad_curl_easy.cpp.
References L, 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 271 of file kicad_curl_easy.cpp.
References KIPLATFORM::ENV::GetSystemProxyConfig(), KIPLATFORM::ENV::PROXY_CONFIG::host, m_CURL, KIPLATFORM::ENV::PROXY_CONFIG::password, setOption(), 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 232 of file kicad_curl_easy.cpp.
References setOption().
      
  | 
  private | 
Definition at line 169 of file kicad_curl_easy.h.
Referenced by GetBuffer(), KICAD_CURL_EASY(), and Perform().
      
  | 
  private | 
Definition at line 167 of file kicad_curl_easy.h.
Referenced by Escape(), GetCurl(), GetResponseStatusCode(), GetTransferTotal(), KICAD_CURL_EASY(), Perform(), setOption(), SetOutputStream(), SetURL(), and ~KICAD_CURL_EASY().
      
  | 
  private | 
Definition at line 171 of file kicad_curl_easy.h.
Referenced by KICAD_CURL_EASY().
      
  | 
  private | 
Definition at line 168 of file kicad_curl_easy.h.
Referenced by KICAD_CURL_EASY(), Perform(), SetHeader(), and ~KICAD_CURL_EASY().
      
  | 
  private | 
Definition at line 170 of file kicad_curl_easy.h.
Referenced by SetTransferCallback().