1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/testing/xpcshell/node-spdy/test/fixtures/frames.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,38 @@ 1.4 +var spdy = require('../../lib/spdy'), 1.5 + Buffer = require('buffer').Buffer; 1.6 + 1.7 +exports.createSynStream = function(host, url, callback) { 1.8 + var deflate = spdy.utils.createDeflate(), 1.9 + chunks = [], 1.10 + chunksTotal = 0, 1.11 + syn_stream; 1.12 + 1.13 + deflate.on('data', function(chunk) { 1.14 + chunks.push(chunk); 1.15 + chunksTotal += chunk.length; 1.16 + }); 1.17 + deflate.write(new Buffer([ 0x00, 0x02, 0x00, 0x04 ])); 1.18 + deflate.write('host'); 1.19 + deflate.write(new Buffer([ 0x00, host.length ])); 1.20 + deflate.write(host); 1.21 + deflate.write(new Buffer([ 0x00, 0x03 ])); 1.22 + deflate.write('url'); 1.23 + deflate.write(new Buffer([ 0x00, url.length ])); 1.24 + deflate.write(url); 1.25 + 1.26 + deflate.flush(function() { 1.27 + syn_stream = new Buffer(18 + chunksTotal); 1.28 + syn_stream.writeUInt32BE(0x80020001, 0); 1.29 + syn_stream.writeUInt32BE(chunksTotal + 8, 4); 1.30 + syn_stream.writeUInt32BE(0x00000001, 8); 1.31 + syn_stream.writeUInt32BE(0x00000000, 12); 1.32 + 1.33 + var offset = 18; 1.34 + chunks.forEach(function(chunk) { 1.35 + chunk.copy(syn_stream, offset); 1.36 + offset += chunk.length; 1.37 + }); 1.38 + 1.39 + callback(syn_stream); 1.40 + }); 1.41 +};