bool GITHUB_GETLIBLIST::remoteGetJSON( const std::string& aFullURLCommand, wxString* aMsgError )
{
    KICAD_CURL_EASY kcurl;

    wxLogDebug( wxT( "Attempting to download: " ) + aFullURLCommand );

    kcurl.SetURL(aFullURLCommand);
    kcurl.SetUserAgent("KiCad-EDA");
    kcurl.SetHeader("Accept", m_option_string);
    kcurl.SetFollowRedirects(true);

    try
    {
        kcurl.Perform();
        m_image.reserve( kcurl.GetBuffer()->Size );
        m_image.assign( kcurl.GetBuffer()->Payload, kcurl.GetBuffer()->Size );
        return true;
    }
    catch( const IO_ERROR& ioe )
    {
        if( aMsgError )
        {
            UTF8 fmt( _( "Error fetching JSON data from URL '%s'.\nReason: '%s'" ) );
            
            std::string msg = StrPrintf( fmt.c_str(), 
                                         aFullURLCommand.c_str(),
                                         TO_UTF8( ioe.errorText ) );

            *aMsgError = FROM_UTF8( msg.c_str() );
        }
        return false;
    }
}
void GITHUB_PLUGIN::remoteGetZip( const wxString& aRepoURL ) throw( IO_ERROR )
{
    std::string  zip_url;

    if( !repoURL_zipURL( aRepoURL, &zip_url ) )
    {
        wxString msg = wxString::Format( _( "Unable to parse URL:\n'%s'" ), GetChars( aRepoURL ) );
        THROW_IO_ERROR( msg );
    }

    wxLogDebug( wxT( "Attempting to download: " ) + zip_url );

    KICAD_CURL_EASY kcurl;      // this can THROW_IO_ERROR

    kcurl.SetURL( zip_url.c_str() );
    kcurl.SetUserAgent( "http://kicad-pcb.org" );
    kcurl.SetHeader( "Accept", "application/zip" );
    kcurl.SetFollowRedirects( true );

    try
    {
        kcurl.Perform();
        m_zip_image = kcurl.GetBuffer();
    }
    catch( const IO_ERROR& ioe )
    {
        // https "GET" has failed, report this to API caller.
        // Note: kcurl.Perform() does not return an error if the file to download is not found
        static const char errorcmd[] = "http GET command failed";  // Do not translate this message

        UTF8 fmt( _( "%s\nCannot get/download Zip archive: '%s'\nfor library path: '%s'.\nReason: '%s'" ) );

        std::string msg = StrPrintf( fmt.c_str(),
                                     errorcmd,
                                     zip_url.c_str(),
                                     TO_UTF8( aRepoURL ),
                                     TO_UTF8( ioe.What() )
                                     );

        THROW_IO_ERROR( msg );
    }

    // If the zip archive is not existing, the received data is "Not Found" or "404: Not Found",
    // and no error is returned by kcurl.Perform().
    if( ( m_zip_image.compare( 0, 9, "Not Found", 9 ) == 0 ) ||
        ( m_zip_image.compare( 0, 14, "404: Not Found", 14 ) == 0 ) )
    {
        UTF8 fmt( _( "Cannot download library '%s'.\nThe library does not exist on the server" ) );
        std::string msg = StrPrintf( fmt.c_str(), TO_UTF8( aRepoURL ) );

        THROW_IO_ERROR( msg );
    }
}