flow ![](https://camo.githubusercontent.com/3f393b1bf50f332a3a7a822d72137d34254c0b48ff62e70819506d462318d01d/68747470733a2f2f6170692e7472617669732d63692e6f72672f722d6c7965682f666c6f772e7376673f6272616e63683d6d6173746572)
- Flow is a lightweight network downloader with native fallbacks. Aimed to gamedev.
- Flow is non-blocking friendly. Support for sync/async requests.
- Flow is tiny. Single header and source files.
- Flow is zlib/libpng licensed.
#include <cassert>
#include <iostream>
#include <string>
#include "flow.hpp"
int main( int argc, const char **argv ) {
auto prompt = []() {
std::string prompt;
while( prompt.empty() ) {
std::cout << "url> ";
std::getline( std::cin, prompt );
}
return prompt;
};
for( ;; ) {
std::string url;
url = prompt();
// sync test
flow::status status = flow::download(url);
std::cout << "sync: "<< status.url << ";ok=" << status.ok << "," << status.data.size() << " bytes;" << status.code << std::endl;
// async test
flow::download_async(url, []( flow::status &status ) {
std::cout << "async: "<< status.url << ";ok=" << status.ok << "," << status.data.size() << " bytes;" << status.code << std::endl;
} );
}
return 0;
}