improved timeout handling and progress bar for autodownloads

http get now uses two timeout values: one for the max time since last
server response, and one for total download time.

When AC is waiting for a server response (before a http header was
received), the progress bar will show the timeout "completion".
This commit is contained in:
ac-stef
2015-09-07 14:53:57 +02:00
parent 0f37595c30
commit 7bdd91bc9f
4 changed files with 25 additions and 16 deletions
+3 -2
View File
@@ -1310,7 +1310,8 @@ bool cllock = false, clfail = false;
int progress_callback_retrieveservers(void *data, float progress)
{
show_out_of_renderloop_progress(min(progress, 1.0f), (const char *)data);
if(progress < 0) show_out_of_renderloop_progress(progress + 1.0f, "waiting for response (esc to abort)");
else show_out_of_renderloop_progress(min(progress, 1.0f), (const char *)data);
return interceptkey(SDLK_ESCAPE) ? 1 : 0;
}
@@ -1329,7 +1330,7 @@ void retrieveservers(vector<char> &data)
defformatstring(url)("/retrieve.do?action=list&name=%s&version=%d&build=%d", urlencode(global_name, true), AC_VERSION, getbuildtype()|(1<<16));
h.outvec = (vector<uchar> *) &data; // ouch...
show_out_of_renderloop_progress(0, progresstext);
h.get(url, RETRIEVELIMIT);
h.get(url, RETRIEVELIMIT, RETRIEVELIMIT);
if(h.response != 200) data.setsize(0);
h.outvec = NULL; // must not be cleaned up by httpget
if(data.length()) data.add('\0');