You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Dont really know if this is my issue, the api issue or cpr itself but im not able to fetch audio files and download them as it gives me a 0 status code which means no response and an empty text, while if i tried downloading it using wget it would actually fetch and download the file.
boolutils::download(const std::string &url, const std::string &path,
const std::string &filename) {
std::string fullPath = path + filename;
if (std::filesystem::exists(fullPath)) {
returntrue;
} else {
std::filesystem::create_directories(path);
}
auto ses = cpr::Session();
ses.SetUrl(cpr::Url{url});
auto ofs = std::ofstream(fullPath);
auto r = ses.Download(ofs);
std::cout << r.status_code << std::endl;
if (r.status_code == 200) {
std::cout << url << " downloaded\n";
returntrue;
} else {
std::cout << "Failed to download " << url << std::endl;
std::cout << r.text << std::endl;
returnfalse;
}
}
wget output:
zeroo@arch ~/P/C/R/build> wget https://resources.download.minecraft.net/46/4696189415397c951c0ec1656af648fc06d62330
--2025-03-03 12:33:57-- https://resources.download.minecraft.net/46/4696189415397c951c0ec1656af648fc06d62330
Loaded CA certificate '/etc/ssl/certs/ca-certificates.crt'
Resolving resources.download.minecraft.net (resources.download.minecraft.net)... 13.107.246.60, 2620:1ec:bdf::60
Connecting to resources.download.minecraft.net (resources.download.minecraft.net)|13.107.246.60|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 58816 (57K) [application/ogg]
Saving to: ‘4696189415397c951c0ec1656af648fc06d62330.1’
4696189415397 100% 57.44K --.-KB/s in 0.03s
2025-03-03 12:33:57 (1.97 MB/s) - ‘4696189415397c951c0ec1656af648fc06d62330.1’ saved [58816/58816]
Example/How to Reproduce
Create a cpr::Session
Set url
create a std::ofstream
Perform the download using session.Download(ofstream)
check the status code and response text
Possible Fix
dont really know man.
Where did you get it from?
GitHub (branch e.g. master)
Additional Context/Your Environment
OS: arch linux x86_64
Version: Linux 6.12.10-zen1-1-zen
The text was updated successfully, but these errors were encountered:
Description
Dont really know if this is my issue, the api issue or cpr itself but im not able to fetch audio files and download them as it gives me a 0 status code which means no response and an empty text, while if i tried downloading it using
wget
it would actually fetch and download the file.wget output:
Example/How to Reproduce
cpr::Session
std::ofstream
session.Download(ofstream)
Possible Fix
dont really know man.
Where did you get it from?
GitHub (branch e.g. master)
Additional Context/Your Environment
The text was updated successfully, but these errors were encountered: