code: function onConnection() {
    var endpoint = new http2.Endpoint(log, 'CLIENT', {});
    endpoint.pipe(socket).pipe(endpoint);
  
    // Sending request
    var stream = endpoint.createStream();
    stream.headers({
      ':method': 'GET',
      ':scheme': url.protocol.slice(0, url.protocol.length - 1),
      ':authority': url.hostname,
      ':path': url.path + (url.hash || '')
    });
  
    // Receiving push streams
    stream.on('promise', function(push_stream, req_headers) {
      var filename = path.join(__dirname, '/push-' + push_count);
      push_count += 1;
      console.error('Receiving pushed resource: ' + req_headers[':path'] + ' -> ' + filename);
      push_stream.pipe(fs.createWriteStream(filename)).on('finish', finish);
    });
  
    // Receiving the response body
    stream.pipe(process.stdout);
    stream.on('end', finish);
  }
docs: Handling the connection