network::Downloader HTTP-CODE 405 (Android only)

Hi,

I had an issue with the network::Downloader (cocos2d-x 3.15.1) on Android.

The used Android library returned a 405 code for a REST call to Firebase (I want use REST, because the SDK is only for Android/iOS and not desktop).

My code looks like:

auto url = "https://XXXX.firebaseio.com/meta/v1.json";
auto file = FileUtils::getInstance()->getWritablePath() + APP_NAME + "_meta.json";
auto downloader = new(std::nothrow) network::Downloader();

downloader->onTaskProgress = ([](const network::DownloadTask &task, int64_t received, int64_t totalReceived, int64_t totalExpected) {
    CCLOG("Progress %l of %l", totalReceived, totalExpected);
});

downloader->onTaskError = ([](const network::DownloadTask &task, int errorCode, int errorCodeInternal, const std::string &errorStr) {
    CCLOG("download failed with error: %s error code: %i error code internal: %i", errorStr.c_str(), errorCode, errorCodeInternal);
});

downloader->onFileTaskSuccess = ([this](const network::DownloadTask &task) {
    CCLOG("Everything was fine...");
});

downloader->createDownloadFileTask(url, file);

And Android had the proper permissions, because I use Firebase Analytics and this is working fine.

What can I do to fix it? My test on iOS and macOS downloaded the file perfect. I did not test Linux, Windows yet.

I switched to simple HttpRequest, because this works within Android. Don’t know what’s wrong with the Downloader yet.