1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/testing/xpcshell/node-spdy/lib/spdy/protocol/generic.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,24 @@ 1.4 +// 1.5 +// ### function parseHeader (data) 1.6 +// ### @data {Buffer} incoming data 1.7 +// Returns parsed SPDY frame header 1.8 +// 1.9 +exports.parseHeader = function parseHeader(data) { 1.10 + var header = { 1.11 + control: (data.readUInt8(0) & 0x80) === 0x80 ? true : false, 1.12 + version: null, 1.13 + type: null, 1.14 + id: null, 1.15 + flags: data.readUInt8(4), 1.16 + length: data.readUInt32BE(4) & 0x00ffffff 1.17 + }; 1.18 + 1.19 + if (header.control) { 1.20 + header.version = data.readUInt16BE(0) & 0x7fff; 1.21 + header.type = data.readUInt16BE(2); 1.22 + } else { 1.23 + header.id = data.readUInt32BE(0) & 0x7fffffff; 1.24 + } 1.25 + 1.26 + return header; 1.27 +};