Hi All,
I'm trying to get the filesize of a file I would like to download, before
doing so. I am able to download the file, that is not the issue. From what
I understood from the docs and some googling is that the below should do
the trick. The result though seems to be a random number, i.e. not -1 in
some unsigned format, like "4.71219e+018".
void DownloadFile ( const std::string url, const fs::path file ) { // fs::
= boost::filesystem::
try {
curlpp::Cleanup cleaner;
curlpp::Easy request;
request.setOpt ( curlpp::options::Url ( url ) );
request.setOpt ( curlpp::options::FollowLocation ( true ) );
request.setOpt ( curlpp::options::Header ( true ) );
request.setOpt ( curlpp::options::NoBody ( true ) );
request.perform ( );
double s = curlpp::infos::ContentLengthDownload::get ( request );
std::cout << s << std::endl;
}
catch ( curlpp::LogicError & e ) {
std::cerr << e.what ( ) << std::endl;
}
catch ( curlpp::RuntimeError & e ) {
std::cerr << e.what ( ) << std::endl;
}
}
The header info returned is:
HTTP/1.1 200 OK
Date: Sun, 08 Sep 2013 13:12:34 GMT
Last-modified: Sun, 21 Jul 2013 10:36:54 GMT
Content-Length: 11044341
Content-Type: application/x-executable
Via: 1.1 www.swi-prolog.org
The value of (in the above) s = 4.71219e+018
The url on which I am testing this is
"http://www.swi-prolog.org/download/stable/bin/w64pl641.exe"
It would be much appreciated if someone could point out my error.
Obviously it's not hard to parse the header myself, but given that curlpp
is so elegantly written, getting this to work the correct way should not be
rocket-science.
Thank you in advance,
degski
--
You received this message because you are subscribed to the Google Groups
"curlpp" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/curlpp.
For more options, visit https://groups.google.com/groups/opt_out.