mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 18:41:51 +00:00
cleanup http requests (part 1)
This commit is contained in:
parent
9a87c20823
commit
74bb695807
6 changed files with 73 additions and 143 deletions
|
|
@ -6,18 +6,20 @@
|
|||
TEST(curltest, curltest) {
|
||||
NetworkSettings settings {};
|
||||
auto network = network::Network::create(settings);
|
||||
network->get(
|
||||
"https://raw.githubusercontent.com/MihailRis/VoxelEngine-Cpp/refs/"
|
||||
"heads/curl/res/content/base/blocks/lamp.json",
|
||||
[](std::vector<char> data) {
|
||||
if (data.empty()) {
|
||||
return;
|
||||
}
|
||||
auto view = std::string_view(data.data(), data.size());
|
||||
auto value = json::parse(view);
|
||||
std::cout << value << std::endl;
|
||||
}, [](auto, auto){}
|
||||
);
|
||||
|
||||
network::HttpRequest request {};
|
||||
request.url = "https://raw.githubusercontent.com/MihailRis/VoxelEngine-Cpp/refs/"
|
||||
"heads/curl/res/content/base/blocks/lamp.json";
|
||||
request.onResponse = [](std::vector<char> data) {
|
||||
if (data.empty()) {
|
||||
return;
|
||||
}
|
||||
auto view = std::string_view(data.data(), data.size());
|
||||
auto value = json::parse(view);
|
||||
std::cout << value << std::endl;
|
||||
};
|
||||
network->request(std::move(request));
|
||||
|
||||
std::cout << "upload: " << network->getTotalUpload() << " B" << std::endl;
|
||||
std::cout << "download: " << network->getTotalDownload() << " B" << std::endl;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue