HTTPClientSession session(uri.getHost(), uri.getPort());
HTTPRequest req(HTTPRequest::HTTP_GET, path, HTTPMessage::HTTP_1_1);
session.setTimeout(Poco::Timespan(20,0));
session.sendRequest(req);
HTTPResponse res;
istream& rs = session.receiveResponse(res);
File saveTo(request.name,File::WriteOnly,true);
char aux_buffer[1024];
rs.read(aux_buffer, 1024);
std::streamsize n = rs.gcount();
while (n > 0){
saveTo.write(aux_buffer,n);
if (rs){
rs.read(aux_buffer, 1024);
n = rs.gcount();
}
else n = 0;
}
}
如何在下载之前获取下载大小?因为有时我得到损坏的文件,所以我想检查大小。