Skip to content

Commit ef90693

Browse files
committed
Some fixes, retrieved from MiniScript
1 parent 25b35c5 commit ef90693

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

src/tdme/network/httpclient/HTTPDownloadClient.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ string HTTPDownloadClient::urlEncode(const string &value) {
9191
return escaped.str();
9292
}
9393

94-
string HTTPDownloadClient::createHTTPRequestHeaders(const string& hostName, const string& relativeUrl) {
94+
const string HTTPDownloadClient::createHTTPRequestHeaders(const string& hostName, const string& relativeUrl) {
9595
string query;
9696
for (const auto& [parameterName, parameterValue]: getParameters) {
9797
if (query.empty() == true) query+= "?"; else query+="&";
@@ -110,8 +110,7 @@ string HTTPDownloadClient::createHTTPRequestHeaders(const string& hostName, cons
110110
for (const auto& [headerName, headerValue]: headers) {
111111
request+= headerName + ": " + headerValue + "\r\n";
112112
}
113-
request+=
114-
string("\r\n");
113+
request+= string("\r\n");
115114
return request;
116115
}
117116

@@ -174,7 +173,7 @@ void HTTPDownloadClient::reset() {
174173
haveContentSize = false;
175174
headerSize = 0LL;
176175
contentSize = 0LL;
177-
finished = true;
176+
finished = false;
178177
progress = 0.0f;
179178
}
180179

@@ -270,7 +269,7 @@ void HTTPDownloadClient::start() {
270269
}
271270

272271
// transfer to real file
273-
if (downloadClient->statusCode == 200 && isStopRequested() == false) {
272+
if (downloadClient->statusCode == HTTP_STATUS_OK && isStopRequested() == false) {
274273
// input file stream
275274
ifstream ifs(std::filesystem::u8path(downloadClient->file + ".download"), ofstream::binary);
276275
if (ifs.is_open() == false) {
@@ -313,6 +312,7 @@ void HTTPDownloadClient::start() {
313312

314313
//
315314
socket->shutdown();
315+
socket = nullptr;
316316

317317
//
318318
downloadClient->progress = 1.0f;

src/tdme/network/httpclient/HTTPDownloadClient.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class tdme::network::httpclient::HTTPDownloadClient {
4747
bool haveContentSize { false };
4848
uint64_t headerSize { 0LL };
4949
uint64_t contentSize { 0LL };
50-
volatile bool finished { true };
50+
volatile bool finished { false };
5151
volatile float progress { 0.0f };
5252

5353
/**
@@ -62,7 +62,7 @@ class tdme::network::httpclient::HTTPDownloadClient {
6262
* @param hostName host name
6363
* @param relativeUrl url relative to server root
6464
*/
65-
string createHTTPRequestHeaders(const string& hostName, const string& relativeUrl);
65+
const string createHTTPRequestHeaders(const string& hostName, const string& relativeUrl);
6666

6767
/**
6868
* Parse HTTP response headers
@@ -264,7 +264,7 @@ class tdme::network::httpclient::HTTPDownloadClient {
264264
* @return HTTP response headers
265265
*/
266266
inline const unordered_map<string, string>& getResponseHeaders() {
267-
return headers;
267+
return responseHeaders;
268268
}
269269

270270
/**

src/tdme/utilities/Console.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ void Console::println(const string_view& str)
7070
//
7171
if (logger != nullptr) logger->println(str);
7272
cout << str << endl;
73+
cout.flush();
7374
//
7475
mutex.unlock();
7576
}
@@ -85,6 +86,7 @@ void Console::print(const string_view& str)
8586
//
8687
if (logger != nullptr) logger->print(str);
8788
cout << str;
89+
cout.flush();
8890
//
8991
mutex.unlock();
9092
}
@@ -99,6 +101,7 @@ void Console::println()
99101
//
100102
if (logger != nullptr) logger->println();
101103
cout << endl;
104+
cout.flush();
102105
//
103106
mutex.unlock();
104107
}

0 commit comments

Comments
 (0)