Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 var fs = require('fs');
2 var path = require('path');
3 var http2 = require('..');
5 http2.globalAgent = new http2.Agent({
6 log: require('../test/util').createLogger('client')
7 });
9 process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
11 // Sending the request
12 // It would be `var request = http2.get(process.argv.pop());` if we wouldn't care about plain mode
13 var options = require('url').parse(process.argv.pop());
14 options.plain = Boolean(process.env.HTTP2_PLAIN);
15 var request = http2.request(options);
16 request.end();
18 // Receiving the response
19 request.on('response', function(response) {
20 response.pipe(process.stdout);
21 response.on('end', finish);
22 });
24 // Receiving push streams
25 request.on('push', function(pushRequest) {
26 var filename = path.join(__dirname, '/push-' + push_count);
27 push_count += 1;
28 console.error('Receiving pushed resource: ' + pushRequest.url + ' -> ' + filename);
29 pushRequest.on('response', function(pushResponse) {
30 pushResponse.pipe(fs.createWriteStream(filename)).on('finish', finish);
31 });
32 });
34 // Quitting after both the response and the associated pushed resources have arrived
35 var push_count = 0;
36 var finished = 0;
37 function finish() {
38 finished += 1;
39 if (finished === (1 + push_count)) {
40 process.exit();
41 }
42 }