Skip to content

Instantly share code, notes, and snippets.

@deanberris
Created September 25, 2012 13:25
Show Gist options
  • Save deanberris/3781810 to your computer and use it in GitHub Desktop.
Save deanberris/3781810 to your computer and use it in GitHub Desktop.
HTTP Client Requests with streaming data.
namespace http = network::http;
namespace util = network::util;
http::client client;
auto fr = client.get(
{"https://www.myservice.com/",
util::gzip_encode(new file_byte_source{"/tmp/data"})}
); // we're gzip encoding the request body
auto r = fr.get();
std::string data = r.read(getpagesize()).get();
while (!data.empty()) {
std::cout << data;
data = r.read(getpagesize()).get();
} // will print data as it comes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment