Bugfixes HTTP::Downloader, downloadertest now outputs data immediately without buffering
This commit is contained in:
parent
bc3ca638cd
commit
e28743db54
2 changed files with 11 additions and 3 deletions
|
@ -331,7 +331,7 @@ namespace HTTP{
|
|||
}
|
||||
|
||||
// No data? Wait for a second or so.
|
||||
if (!getSocket().spool()){
|
||||
if (!getSocket().spool() && getSocket()){
|
||||
if (progressCallback != 0){
|
||||
if (!progressCallback()){
|
||||
WARN_MSG("Download aborted by callback");
|
||||
|
|
|
@ -1,14 +1,22 @@
|
|||
#include "../lib/downloader.cpp"
|
||||
#include <iostream>
|
||||
|
||||
|
||||
class CB : public Util::DataCallback {
|
||||
virtual void dataCallback(const char *ptr, size_t size){
|
||||
std::cout.write(ptr, size);
|
||||
}
|
||||
};
|
||||
CB callback;
|
||||
|
||||
int main(int argc, char **argv){
|
||||
if (argc < 2){
|
||||
std::cout << "Usage: " << argv[0] << " URL" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
HTTP::Downloader d;
|
||||
if (d.get(argv[1])){
|
||||
std::cout << d.data() << std::endl;
|
||||
HTTP::URL url(argv[1]);
|
||||
if (d.get(url, 10, callback)){
|
||||
std::cerr << "Download success!" << std::endl;
|
||||
}else{
|
||||
std::cerr << "Download fail!" << std::endl;
|
||||
|
|
Loading…
Add table
Reference in a new issue