Emscripten: Cosmetics

This commit is contained in:
Tamás Bálint Misius 2023-06-16 12:20:22 +02:00
parent c725894abd
commit 5c816fe1ee
No known key found for this signature in database
GPG Key ID: 5B472A12F6ECA9F2
7 changed files with 14 additions and 13 deletions

View File

@ -88,7 +88,7 @@ namespace http
return handle->state == RequestHandle::done; return handle->state == RequestHandle::done;
} }
std::pair<int, int> Request::CheckProgress() const std::pair<int64_t, int64_t> Request::CheckProgress() const
{ {
std::lock_guard lk(handle->stateMx); std::lock_guard lk(handle->stateMx);
assert(handle->state == RequestHandle::running || handle->state == RequestHandle::done); assert(handle->state == RequestHandle::running || handle->state == RequestHandle::done);

View File

@ -39,7 +39,7 @@ namespace http
void Start(); void Start();
bool CheckDone() const; bool CheckDone() const;
std::pair<int, int> CheckProgress() const; // total, done std::pair<int64_t, int64_t> CheckProgress() const; // total, done
const std::vector<ByteString> &ResponseHeaders() const; const std::vector<ByteString> &ResponseHeaders() const;
void Wait(); void Wait();

View File

@ -221,8 +221,8 @@ namespace http
HandleCURLcode(curl_easy_getinfo(handle->curlEasy, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &total)); // stores -1 if unknown HandleCURLcode(curl_easy_getinfo(handle->curlEasy, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &total)); // stores -1 if unknown
HandleCURLcode(curl_easy_getinfo(handle->curlEasy, CURLINFO_SIZE_DOWNLOAD, &done)); HandleCURLcode(curl_easy_getinfo(handle->curlEasy, CURLINFO_SIZE_DOWNLOAD, &done));
#endif #endif
handle->bytesTotal = int(total); handle->bytesTotal = int64_t(total);
handle->bytesDone = int(done); handle->bytesDone = int64_t(done);
} }
else else
{ {

View File

@ -3,6 +3,7 @@
#include "common/String.h" #include "common/String.h"
#include "client/http/PostData.h" #include "client/http/PostData.h"
#include <atomic> #include <atomic>
#include <cstdint>
#include <thread> #include <thread>
#include <vector> #include <vector>
#include <memory> #include <memory>
@ -38,8 +39,8 @@ namespace http
State state = ready; State state = ready;
std::mutex stateMx; std::mutex stateMx;
std::condition_variable stateCv; std::condition_variable stateCv;
std::atomic<int> bytesTotal = -1; std::atomic<int64_t> bytesTotal = -1;
std::atomic<int> bytesDone = 0; std::atomic<int64_t> bytesDone = 0;
int statusCode = 0; int statusCode = 0;
ByteString responseData; ByteString responseData;
std::vector<ByteString> responseHeaders; std::vector<ByteString> responseHeaders;

View File

@ -58,13 +58,13 @@ inline ByteString IntroText()
{ {
sb << " NOHTTP"; sb << " NOHTTP";
} }
else if constexpr (ENFORCE_HTTPS)
{
sb << " HTTPS";
}
if constexpr (DEBUG) if constexpr (DEBUG)
{ {
sb << " DEBUG"; sb << " DEBUG";
} }
if constexpr (ENFORCE_HTTPS)
{
sb << " HTTPS";
}
return sb.Build(); return sb.Build();
} }

View File

@ -39,7 +39,7 @@ private:
notifyProgress(-1); notifyProgress(-1);
while(!request->CheckDone()) while(!request->CheckDone())
{ {
int total, done; int64_t total, done;
std::tie(total, done) = request->CheckProgress(); std::tie(total, done) = request->CheckProgress();
if (total == -1) if (total == -1)
{ {

View File

@ -103,7 +103,7 @@ public:
return request->CheckDone(); return request->CheckDone();
} }
void Progress(int *total, int *done) void Progress(int64_t *total, int64_t *done)
{ {
if (!dead) if (!dead)
{ {
@ -188,7 +188,7 @@ static int http_request_progress(lua_State *l)
auto *rh = (RequestHandle *)luaL_checkudata(l, 1, "HTTPRequest"); auto *rh = (RequestHandle *)luaL_checkudata(l, 1, "HTTPRequest");
if (!rh->Dead()) if (!rh->Dead())
{ {
int total, done; int64_t total, done;
rh->Progress(&total, &done); rh->Progress(&total, &done);
lua_pushinteger(l, total); lua_pushinteger(l, total);
lua_pushinteger(l, done); lua_pushinteger(l, done);