Skip to content

Instantly share code, notes, and snippets.

@tbfleming
Created January 13, 2018 02:48
Show Gist options
  • Save tbfleming/b7fabe92dd2889ef33375a42701dc66c to your computer and use it in GitHub Desktop.
Save tbfleming/b7fabe92dd2889ef33375a42701dc66c to your computer and use it in GitHub Desktop.
cib demo: emscripten_async_wget_data
// Download a file using https. Only works with sites which support CORS.
#include <emscripten.h>
#include <stdio.h>
#include <string>
using namespace std;
void received(void *, void *data, int size) {
puts(string((char *)data, size).c_str());
}
void error(void *) { printf("download failed\n"); }
int main() {
emscripten_async_wget_data(
"https://cdn.rawgit.com/llvm-mirror/clang/"
"3bddc261ddb5a58ab6dcb502d4889c4ccd5775c4/README.txt",
nullptr, received, error);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment