PrismLauncher/launcher/minecraft/auth/steps/GetSkinStep.cpp
Rachel Powers e8da9ee4fb
feat: Auto handle Http 429 Too Many Requests with retry
- Must be explicitly enabled for a request
- Uses Retry-After Header if present, falls back to exponential back off
  starting with 10 seconds
- if retry delay is greater than 1 minute or it retries more than 3
  times then fail with a "Rate Limited" reason
- Sets task status to inform user of retry.

Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
2026-02-06 09:36:09 -07:00

38 lines
904 B
C++

#include "GetSkinStep.h"
#include <QNetworkRequest>
#include "Application.h"
GetSkinStep::GetSkinStep(AccountData* data) : AuthStep(data) {}
QString GetSkinStep::describe()
{
return tr("Getting skin.");
}
void GetSkinStep::perform()
{
QUrl url(m_data->minecraftProfile.skin.url);
m_response.reset(new QByteArray());
m_request = Net::Download::makeByteArray(url, m_response.get());
m_request->enableAutoRetry(true);
m_task.reset(new NetJob("GetSkinStep", APPLICATION->network()));
m_task->setAskRetry(false);
m_task->addNetAction(m_request);
connect(m_task.get(), &Task::finished, this, &GetSkinStep::onRequestDone);
m_task->start();
}
void GetSkinStep::onRequestDone()
{
if (m_request->error() == QNetworkReply::NoError)
m_data->minecraftProfile.skin.data = *m_response;
emit finished(AccountTaskState::STATE_WORKING, tr("Got skin"));
}