MCPcopy Create free account
hub / github.com/HertzDevil/0CC-FamiTracker / ReadJson

Method ReadJson

Source/VersionChecker.cpp:58–82  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

56 }
57
58 nlohmann::json ReadJson() {
59 if (!hOpen || !hConnect || !hRequest)
60 return nlohmann::json { };
61 if (!HttpSendRequest(hRequest, NULL, 0, NULL, 0))
62 return nlohmann::json { };
63
64 std::string jsonStr;
65 while (true) {
66 DWORD Size;
67 if (!InternetQueryDataAvailable(hRequest, &Size, 0, 0))
68 return nlohmann::json { };
69 if (!Size)
70 break;
71 std::vector<char> Buf(Size + 1);
72 DWORD Received = 0;
73 for (DWORD i = 0; i < Size; i += 1024) {
74 DWORD Length = (Size - i < 1024) ? Size % 1024 : 1024;
75 if (!InternetReadFile(hRequest, Buf.data() + i, Length, &Received))
76 return nlohmann::json { };
77 }
78 jsonStr += Buf.data();
79 }
80
81 return nlohmann::json::parse(jsonStr);
82 }
83
84private:
85 HINTERNET hOpen;

Callers 1

ThreadFnMethod · 0.80

Calls 2

parseFunction · 0.85
dataMethod · 0.45

Tested by

no test coverage detected