Browse Source

KICAD_CURL_EASY: add SetPostFields().

newinvert
Alex Shvartzkop 2 years ago
parent
commit
712d61d2c1
  1. 22
      common/kicad_curl/kicad_curl_easy.cpp
  2. 8
      include/kicad_curl/kicad_curl_easy.h

22
common/kicad_curl/kicad_curl_easy.cpp

@ -230,6 +230,28 @@ bool KICAD_CURL_EASY::SetUserAgent( const std::string& aAgent )
}
bool KICAD_CURL_EASY::SetPostFields(
const std::vector<std::pair<std::string, std::string>>& aFields )
{
std::string postfields;
for( int i = 0; i < aFields.size(); i++ )
{
if( i > 0 )
postfields += "&";
postfields += Escape( aFields[i].first );
postfields += "=";
postfields += Escape( aFields[i].second );
}
if( setOption<const char*>( CURLOPT_COPYPOSTFIELDS, postfields.c_str() ) != CURLE_OK )
return false;
return true;
}
bool KICAD_CURL_EASY::SetURL( const std::string& aURL )
{
if( setOption<const char*>( CURLOPT_URL, aURL.c_str() ) == CURLE_OK )

8
include/kicad_curl/kicad_curl_easy.h

@ -90,6 +90,14 @@ public:
*/
bool SetUserAgent( const std::string& aAgent );
/**
* Set fields for application/x-www-form-urlencoded POST request.
*
* @param aFields is the vector of fields (key-value pairs).
* @return True if successful, false if not.
*/
bool SetPostFields( const std::vector<std::pair<std::string, std::string>>& aFields );
/**
* Set the request URL.
*

Loading…
Cancel
Save