mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-09 03:52:19 +02:00
Retry on unexpected http failures
This commit is contained in:
parent
bb848624d1
commit
f2516b7ab8
1 changed files with 67 additions and 60 deletions
|
@ -82,17 +82,14 @@ static size_t WriteMemoryCallback(void* contents, size_t size, size_t nmemb, voi
|
||||||
void NetRequest::Cleanup()
|
void NetRequest::Cleanup()
|
||||||
{
|
{
|
||||||
if (mCURLMulti != NULL)
|
if (mCURLMulti != NULL)
|
||||||
{
|
|
||||||
curl_multi_remove_handle(mCURLMulti, mCURL);
|
curl_multi_remove_handle(mCURLMulti, mCURL);
|
||||||
}
|
|
||||||
|
|
||||||
if (mCURL != NULL)
|
if (mCURL != NULL)
|
||||||
curl_easy_cleanup(mCURL);
|
curl_easy_cleanup(mCURL);
|
||||||
|
|
||||||
if (mCURLMulti != NULL)
|
if (mCURLMulti != NULL)
|
||||||
{
|
|
||||||
curl_multi_cleanup(mCURLMulti);
|
curl_multi_cleanup(mCURLMulti);
|
||||||
}
|
|
||||||
|
mCURL = NULL;
|
||||||
|
mCURLMulti = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetRequest::DoTransfer()
|
void NetRequest::DoTransfer()
|
||||||
|
@ -105,7 +102,10 @@ void NetRequest::DoTransfer()
|
||||||
// return;
|
// return;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
BfLogDbg("NetManager starting get on %s\n", mURL.c_str());
|
long response_code = 0;
|
||||||
|
for (int pass = 0; pass < 3; pass++)
|
||||||
|
{
|
||||||
|
BfLogDbg("NetManager starting get on %s Pass:%d\n", mURL.c_str(), pass);
|
||||||
mNetManager->mDebugManager->OutputRawMessage(StrFormat("msgLo Getting '%s'\n", mURL.c_str()));
|
mNetManager->mDebugManager->OutputRawMessage(StrFormat("msgLo Getting '%s'\n", mURL.c_str()));
|
||||||
|
|
||||||
mOutTempPath = mOutPath + "__partial";
|
mOutTempPath = mOutPath + "__partial";
|
||||||
|
@ -161,10 +161,17 @@ void NetRequest::DoTransfer()
|
||||||
// return;
|
// return;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
long response_code = 0;
|
response_code = 0;
|
||||||
curl_easy_getinfo(mCURL, CURLINFO_RESPONSE_CODE, &response_code);
|
curl_easy_getinfo(mCURL, CURLINFO_RESPONSE_CODE, &response_code);
|
||||||
mNetManager->mDebugManager->OutputRawMessage(StrFormat("msgLo Result for '%s': %d\n", mURL.c_str(), response_code));
|
mNetManager->mDebugManager->OutputRawMessage(StrFormat("msgLo Result for '%s': %d\n", mURL.c_str(), response_code));
|
||||||
|
|
||||||
|
if ((response_code == 0) || (response_code == 200) || (response_code == 404))
|
||||||
|
break;
|
||||||
|
|
||||||
|
Cleanup();
|
||||||
|
// Try again!
|
||||||
|
}
|
||||||
|
|
||||||
if (response_code == 200)
|
if (response_code == 200)
|
||||||
{
|
{
|
||||||
curl_off_t downloadSize = 0;
|
curl_off_t downloadSize = 0;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue