title: Using gjs, how can you make an async http request to download a file in chunks?
body: <p>I'm starting on my first javascript GTK app and I want to download a file and track it's progress with a Gtk.ProgressBar. The only docs I can find about http requests are some example code here:</p>
  
  <p><a href="http://developer.gnome.org/gnome-devel-demos/unstable/weatherGeonames.js.html.en">http://developer.gnome.org/gnome-devel-demos/unstable/weatherGeonames.js.html.en</a></p>
  
  <p>And some confusing Soup reference here:</p>
  
  <p><a href="http://www.roojs.org/seed/gir-1.2-gtk-3.0/gjs/Soup.SessionAsync.html">http://www.roojs.org/seed/gir-1.2-gtk-3.0/gjs/Soup.SessionAsync.html</a></p>
  
  <p>From what I can gather, I can do something like this:</p>
  
  <pre><code>const Soup = imports.gi.Soup;
  
  var _httpSession = new Soup.SessionAsync();
  Soup.Session.prototype.add_feature.call(_httpSession, new Soup.ProxyResolverDefault());
  
  var request = Soup.Message.new('GET', url);
  _httpSession.queue_message(request, function(_httpSession, message) {
    print('download is done');
  }
  </code></pre>
  
  <p>There only seems to be a callback for when the download is done, and I can't find any way to set a callback function for any data events. How can I do this?</p>
  
  <p>This is really easy in node.js:</p>
  
  <pre><code>var req = http.request(url, function(res){
    console.log('download starting');
    res.on('data', function(chunk) {
      console.log('got a chunk of '+chunk.length+' bytes');
    }); 
  });
  req.end();
  </code></pre>